10Sstevel@tonic-gate/* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52830Sdjl * Common Development and Distribution License (the "License"). 62830Sdjl * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate/* LINTLIBRARY */ 220Sstevel@tonic-gate/* PROTOLIB1 */ 230Sstevel@tonic-gate 240Sstevel@tonic-gate/* 25*12758SJulian.Pullen@Sun.COM *Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 260Sstevel@tonic-gate */ 270Sstevel@tonic-gate 280Sstevel@tonic-gate#include <stdio.h> 290Sstevel@tonic-gate#include <sys/types.h> 300Sstevel@tonic-gate#include <lber.h> 310Sstevel@tonic-gate#include <ldap.h> 320Sstevel@tonic-gate#include "ns_sldap.h" 330Sstevel@tonic-gate 340Sstevel@tonic-gate 350Sstevel@tonic-gate/* 360Sstevel@tonic-gate * Simplified LDAP Naming APIs 370Sstevel@tonic-gate */ 380Sstevel@tonic-gateint __ns_ldap_list( 390Sstevel@tonic-gate const char *service, 400Sstevel@tonic-gate const char *filter, 410Sstevel@tonic-gate int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, 420Sstevel@tonic-gate char **realfilter, const void *userdata), 430Sstevel@tonic-gate const char * const *attribute, 440Sstevel@tonic-gate const ns_cred_t *cred, 450Sstevel@tonic-gate const int flags, 460Sstevel@tonic-gate ns_ldap_result_t ** result, 470Sstevel@tonic-gate ns_ldap_error_t ** errorp, 480Sstevel@tonic-gate int (*callback)(const ns_ldap_entry_t *entry, const void *userdata), 490Sstevel@tonic-gate const void *userdata); 500Sstevel@tonic-gate 51*12758SJulian.Pullen@Sun.COMint __ns_ldap_list_sort( 52*12758SJulian.Pullen@Sun.COM const char *service, 53*12758SJulian.Pullen@Sun.COM const char *filter, 54*12758SJulian.Pullen@Sun.COM const char *sortattr, 55*12758SJulian.Pullen@Sun.COM int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, 56*12758SJulian.Pullen@Sun.COM char **realfilter, const void *userdata), 57*12758SJulian.Pullen@Sun.COM const char * const *attribute, 58*12758SJulian.Pullen@Sun.COM const ns_cred_t *cred, 59*12758SJulian.Pullen@Sun.COM const int flags, 60*12758SJulian.Pullen@Sun.COM ns_ldap_result_t ** result, 61*12758SJulian.Pullen@Sun.COM ns_ldap_error_t ** errorp, 62*12758SJulian.Pullen@Sun.COM int (*callback)(const ns_ldap_entry_t *entry, const void *userdata), 63*12758SJulian.Pullen@Sun.COM const void *userdata); 64*12758SJulian.Pullen@Sun.COM 650Sstevel@tonic-gateint __ns_ldap_addAttr( 660Sstevel@tonic-gate const char *service, 670Sstevel@tonic-gate const char *dn, 680Sstevel@tonic-gate const ns_ldap_attr_t * const *attr, 690Sstevel@tonic-gate const ns_cred_t *cred, 700Sstevel@tonic-gate const int flags, 710Sstevel@tonic-gate ns_ldap_error_t **errorp); 720Sstevel@tonic-gate 730Sstevel@tonic-gateint __ns_ldap_delAttr( 740Sstevel@tonic-gate const char *service, 750Sstevel@tonic-gate const char *dn, 760Sstevel@tonic-gate const ns_ldap_attr_t * const *attr, 770Sstevel@tonic-gate const ns_cred_t *cred, 780Sstevel@tonic-gate const int flags, 790Sstevel@tonic-gate ns_ldap_error_t **errorp); 800Sstevel@tonic-gate 810Sstevel@tonic-gateint __ns_ldap_repAttr( 820Sstevel@tonic-gate const char *service, 830Sstevel@tonic-gate const char *dn, 840Sstevel@tonic-gate const ns_ldap_attr_t * const *attr, 850Sstevel@tonic-gate const ns_cred_t *cred, 860Sstevel@tonic-gate const int flags, 870Sstevel@tonic-gate ns_ldap_error_t **errorp); 880Sstevel@tonic-gate 890Sstevel@tonic-gateint __ns_ldap_addEntry( 900Sstevel@tonic-gate const char *service, 910Sstevel@tonic-gate const char *dn, 920Sstevel@tonic-gate const ns_ldap_entry_t *entry, 930Sstevel@tonic-gate const ns_cred_t *cred, 940Sstevel@tonic-gate const int flags, 950Sstevel@tonic-gate ns_ldap_error_t **errorp); 960Sstevel@tonic-gate 970Sstevel@tonic-gateint __ns_ldap_addTypedEntry( 980Sstevel@tonic-gate const char *servicetype, 990Sstevel@tonic-gate const char *basedn, 1000Sstevel@tonic-gate const void *data, 1010Sstevel@tonic-gate const int create, 1020Sstevel@tonic-gate const ns_cred_t *cred, 1030Sstevel@tonic-gate const int flags, 1040Sstevel@tonic-gate ns_ldap_error_t **errorp); 1050Sstevel@tonic-gate 1060Sstevel@tonic-gateint __ns_ldap_delEntry( 1070Sstevel@tonic-gate const char *service, 1080Sstevel@tonic-gate const char *dn, 1090Sstevel@tonic-gate const ns_cred_t *cred, 1100Sstevel@tonic-gate const int flags, 1110Sstevel@tonic-gate ns_ldap_error_t **errorp); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gateint __ns_ldap_firstEntry( 1140Sstevel@tonic-gate const char *service, 1150Sstevel@tonic-gate const char *filter, 116*12758SJulian.Pullen@Sun.COM const char *sortattr, 1170Sstevel@tonic-gate int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, 1180Sstevel@tonic-gate char **realfilter, const void *userdata), 1190Sstevel@tonic-gate const char * const *attribute, 1200Sstevel@tonic-gate const ns_cred_t *cred, 1210Sstevel@tonic-gate const int flags, 1220Sstevel@tonic-gate void **cookie, 1230Sstevel@tonic-gate ns_ldap_result_t ** result, 1240Sstevel@tonic-gate ns_ldap_error_t **errorp, 1250Sstevel@tonic-gate const void *userdata); 1260Sstevel@tonic-gate 1270Sstevel@tonic-gateint __ns_ldap_nextEntry( 1280Sstevel@tonic-gate void *cookie, 1290Sstevel@tonic-gate ns_ldap_result_t ** result, 1300Sstevel@tonic-gate ns_ldap_error_t **errorp); 1310Sstevel@tonic-gate 1320Sstevel@tonic-gateint __ns_ldap_endEntry( 1330Sstevel@tonic-gate void **cookie, 1340Sstevel@tonic-gate ns_ldap_error_t **errorp); 1350Sstevel@tonic-gate 1360Sstevel@tonic-gateint __ns_ldap_freeResult( 1370Sstevel@tonic-gate ns_ldap_result_t **result); 1380Sstevel@tonic-gate 1390Sstevel@tonic-gateint __ns_ldap_freeError( 1400Sstevel@tonic-gate ns_ldap_error_t **errorp); 1410Sstevel@tonic-gate 1420Sstevel@tonic-gateint __ns_ldap_freeCookie( 1430Sstevel@tonic-gate void **cookie); 1440Sstevel@tonic-gate 1450Sstevel@tonic-gateint __ns_ldap_uid2dn( 1460Sstevel@tonic-gate const char *uid, 1470Sstevel@tonic-gate char **userDN, 1480Sstevel@tonic-gate const ns_cred_t *cred, 1490Sstevel@tonic-gate ns_ldap_error_t ** errorp); 1500Sstevel@tonic-gate 1510Sstevel@tonic-gateint __ns_ldap_host2dn( 1520Sstevel@tonic-gate const char *host, 1530Sstevel@tonic-gate const char *domain, 1540Sstevel@tonic-gate char **hostDN, 1550Sstevel@tonic-gate const ns_cred_t *cred, 1560Sstevel@tonic-gate ns_ldap_error_t ** errorp); 1570Sstevel@tonic-gate 1580Sstevel@tonic-gateint __ns_ldap_dn2domain( 1590Sstevel@tonic-gate const char *dn, 1600Sstevel@tonic-gate char **domain, 1610Sstevel@tonic-gate const ns_cred_t *cred, 1620Sstevel@tonic-gate ns_ldap_error_t **errorp); 1630Sstevel@tonic-gate 1640Sstevel@tonic-gateint __ns_ldap_auth( 1650Sstevel@tonic-gate const ns_cred_t *cred, 1660Sstevel@tonic-gate const int flag, 1670Sstevel@tonic-gate ns_ldap_error_t **errorp, 1680Sstevel@tonic-gate LDAPControl **serverctrls, 1690Sstevel@tonic-gate LDAPControl **clientctrls); 1700Sstevel@tonic-gate 1710Sstevel@tonic-gateint __ns_ldap_err2str( 1720Sstevel@tonic-gate int err, 1730Sstevel@tonic-gate char **strmsg); 1740Sstevel@tonic-gate 1750Sstevel@tonic-gateint __ns_ldap_setParam( 1760Sstevel@tonic-gate const ParamIndexType type, 1770Sstevel@tonic-gate const void *data, 1780Sstevel@tonic-gate ns_ldap_error_t **errorp); 1790Sstevel@tonic-gate 1800Sstevel@tonic-gateint __ns_ldap_getParam( 1810Sstevel@tonic-gate const ParamIndexType type, 1820Sstevel@tonic-gate void ***data, 1830Sstevel@tonic-gate ns_ldap_error_t **errorp); 1840Sstevel@tonic-gate 1850Sstevel@tonic-gateint __ns_ldap_freeParam( 1860Sstevel@tonic-gate void ***data); 1870Sstevel@tonic-gate 1880Sstevel@tonic-gatechar **__ns_ldap_getAttr( 1890Sstevel@tonic-gate const ns_ldap_entry_t *entry, 1900Sstevel@tonic-gate const char *attrname); 1910Sstevel@tonic-gate 1920Sstevel@tonic-gateint __s_api_prepend_automountmapname_to_dn( 1930Sstevel@tonic-gate const char *service, 1940Sstevel@tonic-gate char **basedn, 1950Sstevel@tonic-gate ns_ldap_error_t ** errorp); 1960Sstevel@tonic-gate 1970Sstevel@tonic-gatechar *__s_api_get_canonical_name( 1980Sstevel@tonic-gate ns_ldap_entry_t *entry, 1990Sstevel@tonic-gate ns_ldap_attr_t *attrptr, 2000Sstevel@tonic-gate int case_ignore); 2012830Sdjl 2022830Sdjlvoid __ns_ldap_setServer( 2032830Sdjl int set); 2042830Sdjl 2052830Sdjlns_ldap_error_t *__ns_ldap_LoadConfiguration( 2062830Sdjl void); 2072830Sdjl 2082830Sdjlns_ldap_error_t *__ns_ldap_DumpConfiguration( 2092830Sdjl char *file); 2102830Sdjl 2112830Sdjlns_ldap_error_t *__ns_ldap_DumpLdif( 2122830Sdjl char *filename); 2132830Sdjl 2142830Sdjlns_ldap_error_t *__ns_ldap_print_config( 2152830Sdjl int verbose); 2162830Sdjl 2172830Sdjlvoid __ns_ldap_default_config( 2182830Sdjl void); 2192830Sdjl 2202830Sdjlint __ns_ldap_download( 2212830Sdjl const char *profile, 2222830Sdjl char *addr, 2232830Sdjl char *baseDN, 2242830Sdjl ns_ldap_error_t **errorp); 2252830Sdjl 2262830Sdjlint __ns_ldap_check_dns_preq( 2272830Sdjl int foreground, 2282830Sdjl int mode_verbose, 2292830Sdjl int mode_quiet, 2302830Sdjl const char *fname, 2312830Sdjl ns_ldap_self_gssapi_config_t config, 2322830Sdjl ns_ldap_error_t **errpp); 2332830Sdjl 2342830Sdjlint __ns_ldap_check_gssapi_preq( 2352830Sdjl int foreground, 2362830Sdjl int mode_verbose, 2372830Sdjl int mode_quiet, 2382830Sdjl ns_ldap_self_gssapi_config_t config, 2392830Sdjl ns_ldap_error_t **errpp); 2402830Sdjl 2412830Sdjlint __ns_ldap_check_all_preq( 2422830Sdjl int foreground, 2432830Sdjl int mode_verbose, 2442830Sdjl int mode_quiet, 2452830Sdjl ns_ldap_self_gssapi_config_t config, 2462830Sdjl ns_ldap_error_t **errpp); 247