17c478bd9Sstevel@tonic-gate/* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5cb5caa98Sdjl * Common Development and Distribution License (the "License"). 6cb5caa98Sdjl * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate/* LINTLIBRARY */ 227c478bd9Sstevel@tonic-gate/* PROTOLIB1 */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate/* 25*9f2fd570SJulian Pullen *Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate#include <stdio.h> 297c478bd9Sstevel@tonic-gate#include <sys/types.h> 307c478bd9Sstevel@tonic-gate#include <lber.h> 317c478bd9Sstevel@tonic-gate#include <ldap.h> 327c478bd9Sstevel@tonic-gate#include "ns_sldap.h" 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate/* 367c478bd9Sstevel@tonic-gate * Simplified LDAP Naming APIs 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gateint __ns_ldap_list( 397c478bd9Sstevel@tonic-gate const char *service, 407c478bd9Sstevel@tonic-gate const char *filter, 417c478bd9Sstevel@tonic-gate int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, 427c478bd9Sstevel@tonic-gate char **realfilter, const void *userdata), 437c478bd9Sstevel@tonic-gate const char * const *attribute, 447c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 457c478bd9Sstevel@tonic-gate const int flags, 467c478bd9Sstevel@tonic-gate ns_ldap_result_t ** result, 477c478bd9Sstevel@tonic-gate ns_ldap_error_t ** errorp, 487c478bd9Sstevel@tonic-gate int (*callback)(const ns_ldap_entry_t *entry, const void *userdata), 497c478bd9Sstevel@tonic-gate const void *userdata); 507c478bd9Sstevel@tonic-gate 51*9f2fd570SJulian Pullenint __ns_ldap_list_sort( 52*9f2fd570SJulian Pullen const char *service, 53*9f2fd570SJulian Pullen const char *filter, 54*9f2fd570SJulian Pullen const char *sortattr, 55*9f2fd570SJulian Pullen int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, 56*9f2fd570SJulian Pullen char **realfilter, const void *userdata), 57*9f2fd570SJulian Pullen const char * const *attribute, 58*9f2fd570SJulian Pullen const ns_cred_t *cred, 59*9f2fd570SJulian Pullen const int flags, 60*9f2fd570SJulian Pullen ns_ldap_result_t ** result, 61*9f2fd570SJulian Pullen ns_ldap_error_t ** errorp, 62*9f2fd570SJulian Pullen int (*callback)(const ns_ldap_entry_t *entry, const void *userdata), 63*9f2fd570SJulian Pullen const void *userdata); 64*9f2fd570SJulian Pullen 657c478bd9Sstevel@tonic-gateint __ns_ldap_addAttr( 667c478bd9Sstevel@tonic-gate const char *service, 677c478bd9Sstevel@tonic-gate const char *dn, 687c478bd9Sstevel@tonic-gate const ns_ldap_attr_t * const *attr, 697c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 707c478bd9Sstevel@tonic-gate const int flags, 717c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gateint __ns_ldap_delAttr( 747c478bd9Sstevel@tonic-gate const char *service, 757c478bd9Sstevel@tonic-gate const char *dn, 767c478bd9Sstevel@tonic-gate const ns_ldap_attr_t * const *attr, 777c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 787c478bd9Sstevel@tonic-gate const int flags, 797c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gateint __ns_ldap_repAttr( 827c478bd9Sstevel@tonic-gate const char *service, 837c478bd9Sstevel@tonic-gate const char *dn, 847c478bd9Sstevel@tonic-gate const ns_ldap_attr_t * const *attr, 857c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 867c478bd9Sstevel@tonic-gate const int flags, 877c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gateint __ns_ldap_addEntry( 907c478bd9Sstevel@tonic-gate const char *service, 917c478bd9Sstevel@tonic-gate const char *dn, 927c478bd9Sstevel@tonic-gate const ns_ldap_entry_t *entry, 937c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 947c478bd9Sstevel@tonic-gate const int flags, 957c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gateint __ns_ldap_addTypedEntry( 987c478bd9Sstevel@tonic-gate const char *servicetype, 997c478bd9Sstevel@tonic-gate const char *basedn, 1007c478bd9Sstevel@tonic-gate const void *data, 1017c478bd9Sstevel@tonic-gate const int create, 1027c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 1037c478bd9Sstevel@tonic-gate const int flags, 1047c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gateint __ns_ldap_delEntry( 1077c478bd9Sstevel@tonic-gate const char *service, 1087c478bd9Sstevel@tonic-gate const char *dn, 1097c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 1107c478bd9Sstevel@tonic-gate const int flags, 1117c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gateint __ns_ldap_firstEntry( 1147c478bd9Sstevel@tonic-gate const char *service, 1157c478bd9Sstevel@tonic-gate const char *filter, 116*9f2fd570SJulian Pullen const char *sortattr, 1177c478bd9Sstevel@tonic-gate int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, 1187c478bd9Sstevel@tonic-gate char **realfilter, const void *userdata), 1197c478bd9Sstevel@tonic-gate const char * const *attribute, 1207c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 1217c478bd9Sstevel@tonic-gate const int flags, 1227c478bd9Sstevel@tonic-gate void **cookie, 1237c478bd9Sstevel@tonic-gate ns_ldap_result_t ** result, 1247c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp, 1257c478bd9Sstevel@tonic-gate const void *userdata); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gateint __ns_ldap_nextEntry( 1287c478bd9Sstevel@tonic-gate void *cookie, 1297c478bd9Sstevel@tonic-gate ns_ldap_result_t ** result, 1307c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gateint __ns_ldap_endEntry( 1337c478bd9Sstevel@tonic-gate void **cookie, 1347c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gateint __ns_ldap_freeResult( 1377c478bd9Sstevel@tonic-gate ns_ldap_result_t **result); 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gateint __ns_ldap_freeError( 1407c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gateint __ns_ldap_freeCookie( 1437c478bd9Sstevel@tonic-gate void **cookie); 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gateint __ns_ldap_uid2dn( 1467c478bd9Sstevel@tonic-gate const char *uid, 1477c478bd9Sstevel@tonic-gate char **userDN, 1487c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 1497c478bd9Sstevel@tonic-gate ns_ldap_error_t ** errorp); 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gateint __ns_ldap_host2dn( 1527c478bd9Sstevel@tonic-gate const char *host, 1537c478bd9Sstevel@tonic-gate const char *domain, 1547c478bd9Sstevel@tonic-gate char **hostDN, 1557c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 1567c478bd9Sstevel@tonic-gate ns_ldap_error_t ** errorp); 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gateint __ns_ldap_dn2domain( 1597c478bd9Sstevel@tonic-gate const char *dn, 1607c478bd9Sstevel@tonic-gate char **domain, 1617c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 1627c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gateint __ns_ldap_auth( 1657c478bd9Sstevel@tonic-gate const ns_cred_t *cred, 1667c478bd9Sstevel@tonic-gate const int flag, 1677c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp, 1687c478bd9Sstevel@tonic-gate LDAPControl **serverctrls, 1697c478bd9Sstevel@tonic-gate LDAPControl **clientctrls); 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gateint __ns_ldap_err2str( 1727c478bd9Sstevel@tonic-gate int err, 1737c478bd9Sstevel@tonic-gate char **strmsg); 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gateint __ns_ldap_setParam( 1767c478bd9Sstevel@tonic-gate const ParamIndexType type, 1777c478bd9Sstevel@tonic-gate const void *data, 1787c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gateint __ns_ldap_getParam( 1817c478bd9Sstevel@tonic-gate const ParamIndexType type, 1827c478bd9Sstevel@tonic-gate void ***data, 1837c478bd9Sstevel@tonic-gate ns_ldap_error_t **errorp); 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gateint __ns_ldap_freeParam( 1867c478bd9Sstevel@tonic-gate void ***data); 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gatechar **__ns_ldap_getAttr( 1897c478bd9Sstevel@tonic-gate const ns_ldap_entry_t *entry, 1907c478bd9Sstevel@tonic-gate const char *attrname); 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gateint __s_api_prepend_automountmapname_to_dn( 1937c478bd9Sstevel@tonic-gate const char *service, 1947c478bd9Sstevel@tonic-gate char **basedn, 1957c478bd9Sstevel@tonic-gate ns_ldap_error_t ** errorp); 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gatechar *__s_api_get_canonical_name( 1987c478bd9Sstevel@tonic-gate ns_ldap_entry_t *entry, 1997c478bd9Sstevel@tonic-gate ns_ldap_attr_t *attrptr, 2007c478bd9Sstevel@tonic-gate int case_ignore); 201cb5caa98Sdjl 202cb5caa98Sdjlvoid __ns_ldap_setServer( 203cb5caa98Sdjl int set); 204cb5caa98Sdjl 205cb5caa98Sdjlns_ldap_error_t *__ns_ldap_LoadConfiguration( 206cb5caa98Sdjl void); 207cb5caa98Sdjl 208cb5caa98Sdjlns_ldap_error_t *__ns_ldap_DumpConfiguration( 209cb5caa98Sdjl char *file); 210cb5caa98Sdjl 211cb5caa98Sdjlns_ldap_error_t *__ns_ldap_DumpLdif( 212cb5caa98Sdjl char *filename); 213cb5caa98Sdjl 214cb5caa98Sdjlns_ldap_error_t *__ns_ldap_print_config( 215cb5caa98Sdjl int verbose); 216cb5caa98Sdjl 217cb5caa98Sdjlvoid __ns_ldap_default_config( 218cb5caa98Sdjl void); 219cb5caa98Sdjl 220cb5caa98Sdjlint __ns_ldap_download( 221cb5caa98Sdjl const char *profile, 222cb5caa98Sdjl char *addr, 223cb5caa98Sdjl char *baseDN, 224cb5caa98Sdjl ns_ldap_error_t **errorp); 225cb5caa98Sdjl 226cb5caa98Sdjlint __ns_ldap_check_dns_preq( 227cb5caa98Sdjl int foreground, 228cb5caa98Sdjl int mode_verbose, 229cb5caa98Sdjl int mode_quiet, 230cb5caa98Sdjl const char *fname, 231cb5caa98Sdjl ns_ldap_self_gssapi_config_t config, 232cb5caa98Sdjl ns_ldap_error_t **errpp); 233cb5caa98Sdjl 234cb5caa98Sdjlint __ns_ldap_check_gssapi_preq( 235cb5caa98Sdjl int foreground, 236cb5caa98Sdjl int mode_verbose, 237cb5caa98Sdjl int mode_quiet, 238cb5caa98Sdjl ns_ldap_self_gssapi_config_t config, 239cb5caa98Sdjl ns_ldap_error_t **errpp); 240cb5caa98Sdjl 241cb5caa98Sdjlint __ns_ldap_check_all_preq( 242cb5caa98Sdjl int foreground, 243cb5caa98Sdjl int mode_verbose, 244cb5caa98Sdjl int mode_quiet, 245cb5caa98Sdjl ns_ldap_self_gssapi_config_t config, 246cb5caa98Sdjl ns_ldap_error_t **errpp); 247