1 /* 2 * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* 7 * The contents of this file are subject to the Netscape Public 8 * License Version 1.1 (the "License"); you may not use this file 9 * except in compliance with the License. You may obtain a copy of 10 * the License at http://www.mozilla.org/NPL/ 11 * 12 * Software distributed under the License is distributed on an "AS 13 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 14 * implied. See the License for the specific language governing 15 * rights and limitations under the License. 16 * 17 * The Original Code is Mozilla Communicator client code, released 18 * March 31, 1998. 19 * 20 * The Initial Developer of the Original Code is Netscape 21 * Communications Corporation. Portions created by Netscape are 22 * Copyright (C) 1998-1999 Netscape Communications Corporation. All 23 * Rights Reserved. 24 * 25 * Contributor(s): 26 */ 27 28 #ifndef _LDAP_H 29 #define _LDAP_H 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #ifndef _SOLARIS_SDK 38 #define _SOLARIS_SDK 39 #endif 40 41 #ifndef LDAP_TYPE_TIMEVAL_DEFINED 42 #include <sys/time.h> 43 #endif 44 #ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ 45 #include <sys/types.h> 46 #include <sys/socket.h> 47 #endif 48 49 #include <lber.h> 50 51 #define LDAP_PORT 389 52 #define LDAPS_PORT 636 53 #define LDAP_PORT_MAX 65535 /* API extension */ 54 #define LDAP_VERSION1 1 /* API extension */ 55 #define LDAP_VERSION2 2 56 #define LDAP_VERSION3 3 57 #define LDAP_VERSION LDAP_VERSION2 /* API extension */ 58 #define LDAP_VERSION_MIN LDAP_VERSION3 59 #define LDAP_VERSION_MAX LDAP_VERSION3 60 61 #define LDAP_VENDOR_VERSION 500 /* version # * 100 */ 62 #define LDAP_VENDOR_NAME "Sun Microsystems Inc." 63 /* 64 * The following will be an RFC number once the LDAP C API Internet Draft 65 * is published as a Proposed Standard RFC. For now we use 2000 + the 66 * draft revision number (currently 5) since we are close to compliance 67 * with revision 5 of the draft. 68 */ 69 #define LDAP_API_VERSION 2005 70 71 /* 72 * C LDAP features we support that are not (yet) part of the LDAP C API 73 * Internet Draft. Use the ldap_get_option() call with an option value of 74 * LDAP_OPT_API_FEATURE_INFO to retrieve information about a feature. 75 * 76 * Note that this list is incomplete; it includes only the most widely 77 * used extensions. Also, the version is 1 for all of these for now. 78 */ 79 #define LDAP_API_FEATURE_SERVER_SIDE_SORT 1 80 #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1 81 #define LDAP_API_FEATURE_PERSISTENT_SEARCH 1 82 #define LDAP_API_FEATURE_PROXY_AUTHORIZATION 1 83 #define LDAP_API_FEATURE_X_LDERRNO 1 84 #define LDAP_API_FEATURE_X_MEMCACHE 1 85 #define LDAP_API_FEATURE_X_IO_FUNCTIONS 1 86 #define LDAP_API_FEATURE_X_EXTIO_FUNCTIONS 1 87 #define LDAP_API_FEATURE_X_DNS_FUNCTIONS 1 88 #define LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS 1 89 #define LDAP_API_FEATURE_X_THREAD_FUNCTIONS 1 90 #define LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS 1 91 #define LDAP_API_FEATURE_X_GETLANGVALUES 1 92 #define LDAP_API_FEATURE_X_CLIENT_SIDE_SORT 1 93 #define LDAP_API_FEATURE_X_URL_FUNCTIONS 1 94 #define LDAP_API_FEATURE_X_FILTER_FUNCTIONS 1 95 96 #define LDAP_ROOT_DSE "" /* API extension */ 97 #define LDAP_NO_ATTRS "1.1" 98 #define LDAP_ALL_USER_ATTRS "*" 99 100 /* 101 * Standard options (used with ldap_set_option() and ldap_get_option): 102 */ 103 #define LDAP_OPT_API_INFO 0x00 /* 0 */ 104 #define LDAP_OPT_DESC 0x01 /* 1 */ 105 #define LDAP_OPT_DEREF 0x02 /* 2 */ 106 #define LDAP_OPT_SIZELIMIT 0x03 /* 3 */ 107 #define LDAP_OPT_TIMELIMIT 0x04 /* 4 */ 108 #define LDAP_OPT_REFERRALS 0x08 /* 8 */ 109 #define LDAP_OPT_RESTART 0x09 /* 9 */ 110 #define LDAP_OPT_PROTOCOL_VERSION 0x11 /* 17 */ 111 #define LDAP_OPT_SERVER_CONTROLS 0x12 /* 18 */ 112 #define LDAP_OPT_CLIENT_CONTROLS 0x13 /* 19 */ 113 #define LDAP_OPT_API_FEATURE_INFO 0x15 /* 21 */ 114 #define LDAP_OPT_HOST_NAME 0x30 /* 48 */ 115 #define LDAP_OPT_ERROR_NUMBER 0x31 /* 49 */ 116 #define LDAP_OPT_ERROR_STRING 0x32 /* 50 */ 117 #define LDAP_OPT_MATCHED_DN 0x33 /* 51 */ 118 119 /* 120 * Well-behaved private and experimental extensions will use option values 121 * between 0x4000 (16384) and 0x7FFF (32767) inclusive. 122 */ 123 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x4000 /* to 0x7FFF inclusive */ 124 /* 125 * Special timeout values for poll and connect: 126 */ 127 #define LDAP_X_IO_TIMEOUT_NO_WAIT 0 /* return immediately */ 128 #define LDAP_X_IO_TIMEOUT_NO_TIMEOUT (-1) /* block indefinitely */ 129 /* 130 * Timeout value for nonblocking connect call 131 */ 132 #define LDAP_X_OPT_CONNECT_TIMEOUT (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01) 133 /* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */ 134 135 /* for on/off options */ 136 #define LDAP_OPT_ON ((void *)1) 137 #define LDAP_OPT_OFF ((void *)0) 138 139 typedef struct ldap LDAP; /* opaque connection handle */ 140 typedef struct ldapmsg LDAPMessage; /* opaque result/entry handle */ 141 142 #define NULLMSG ((LDAPMessage *)0) 143 144 /* structure representing an LDAP modification */ 145 typedef struct ldapmod { 146 int mod_op; /* kind of mod + form of values */ 147 #define LDAP_MOD_ADD 0x00 148 #define LDAP_MOD_DELETE 0x01 149 #define LDAP_MOD_REPLACE 0x02 150 #define LDAP_MOD_BVALUES 0x80 151 char *mod_type; /* attribute name to modify */ 152 union mod_vals_u { 153 char **modv_strvals; 154 struct berval **modv_bvals; 155 } mod_vals; /* values to add/delete/replace */ 156 #define mod_values mod_vals.modv_strvals 157 #define mod_bvalues mod_vals.modv_bvals 158 } LDAPMod; 159 160 161 /* 162 * structure for holding ldapv3 controls 163 */ 164 typedef struct ldapcontrol { 165 char *ldctl_oid; 166 struct berval ldctl_value; 167 char ldctl_iscritical; 168 } LDAPControl; 169 170 171 /* 172 * LDAP API information. Can be retrieved by using a sequence like: 173 * 174 * LDAPAPIInfo ldai; 175 * ldai.ldapai_info_version = LDAP_API_INFO_VERSION; 176 * if ( ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldia ) == 0 ) ... 177 */ 178 #define LDAP_API_INFO_VERSION 1 179 typedef struct ldapapiinfo { 180 int ldapai_info_version; /* version of this struct (1) */ 181 int ldapai_api_version; /* revision of API supported */ 182 int ldapai_protocol_version; /* highest LDAP version supported */ 183 char **ldapai_extensions; /* names of API extensions */ 184 char *ldapai_vendor_name; /* name of supplier */ 185 int ldapai_vendor_version; /* supplier-specific version times 100 */ 186 } LDAPAPIInfo; 187 188 189 /* 190 * LDAP API extended features info. Can be retrieved by using a sequence like: 191 * 192 * LDAPAPIFeatureInfo ldfi; 193 * ldfi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION; 194 * ldfi.ldapaif_name = "VIRTUAL_LIST_VIEW"; 195 * if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &ldfi ) == 0 ) ... 196 */ 197 #define LDAP_FEATURE_INFO_VERSION 1 198 typedef struct ldap_apifeature_info { 199 int ldapaif_info_version; /* version of this struct (1) */ 200 char *ldapaif_name; /* name of supported feature */ 201 int ldapaif_version; /* revision of supported feature */ 202 } LDAPAPIFeatureInfo; 203 204 205 /* possible result types a server can return */ 206 #define LDAP_RES_BIND 0x61 /* 97 */ 207 #define LDAP_RES_SEARCH_ENTRY 0x64 /* 100 */ 208 #define LDAP_RES_SEARCH_RESULT 0x65 /* 101 */ 209 #define LDAP_RES_MODIFY 0x67 /* 103 */ 210 #define LDAP_RES_ADD 0x69 /* 105 */ 211 #define LDAP_RES_DELETE 0x6b /* 107 */ 212 #define LDAP_RES_MODDN 0x6d /* 109 */ 213 #define LDAP_RES_COMPARE 0x6f /* 111 */ 214 #define LDAP_RES_SEARCH_REFERENCE 0x73 /* 115 */ 215 #define LDAP_RES_EXTENDED 0x78 /* 120 */ 216 217 /* Special values for ldap_result() "msgid" parameter */ 218 #define LDAP_RES_ANY (-1) 219 #define LDAP_RES_UNSOLICITED 0 220 221 /* built-in SASL methods */ 222 #define LDAP_SASL_SIMPLE 0 /* special value used for simple bind */ 223 #define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */ 224 225 #ifdef _SOLARIS_SDK 226 #define LDAP_SASL_CRAM_MD5 "CRAM-MD5" 227 #define LDAP_SASL_DIGEST_MD5 "DIGEST-MD5" 228 #define LDAP_SASL_BIND_INPROGRESS 0x0e /* for backward compatibility */ 229 #endif 230 231 /* search scopes */ 232 #define LDAP_SCOPE_BASE 0x00 233 #define LDAP_SCOPE_ONELEVEL 0x01 234 #define LDAP_SCOPE_SUBTREE 0x02 235 236 /* alias dereferencing */ 237 #define LDAP_DEREF_NEVER 0 238 #define LDAP_DEREF_SEARCHING 1 239 #define LDAP_DEREF_FINDING 2 240 #define LDAP_DEREF_ALWAYS 3 241 242 /* predefined size/time limits */ 243 #define LDAP_NO_LIMIT 0 244 245 /* allowed values for "all" ldap_result() parameter */ 246 #define LDAP_MSG_ONE 0 247 #define LDAP_MSG_ALL 1 248 #define LDAP_MSG_RECEIVED 2 249 250 /* possible error codes we can be returned */ 251 #define LDAP_SUCCESS 0x00 /* 0 */ 252 #define LDAP_OPERATIONS_ERROR 0x01 /* 1 */ 253 #define LDAP_PROTOCOL_ERROR 0x02 /* 2 */ 254 #define LDAP_TIMELIMIT_EXCEEDED 0x03 /* 3 */ 255 #define LDAP_SIZELIMIT_EXCEEDED 0x04 /* 4 */ 256 #define LDAP_COMPARE_FALSE 0x05 /* 5 */ 257 #define LDAP_COMPARE_TRUE 0x06 /* 6 */ 258 #define LDAP_STRONG_AUTH_NOT_SUPPORTED 0x07 /* 7 */ 259 #define LDAP_STRONG_AUTH_REQUIRED 0x08 /* 8 */ 260 #define LDAP_PARTIAL_RESULTS 0x09 /* 9 (UMich LDAPv2 extn) */ 261 #define LDAP_REFERRAL 0x0a /* 10 - LDAPv3 */ 262 #define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* 11 - LDAPv3 */ 263 #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* 12 - LDAPv3 */ 264 #define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* 13 */ 265 #define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* 14 - LDAPv3 */ 266 267 #define LDAP_NO_SUCH_ATTRIBUTE 0x10 /* 16 */ 268 #define LDAP_UNDEFINED_TYPE 0x11 /* 17 */ 269 #define LDAP_INAPPROPRIATE_MATCHING 0x12 /* 18 */ 270 #define LDAP_CONSTRAINT_VIOLATION 0x13 /* 19 */ 271 #define LDAP_TYPE_OR_VALUE_EXISTS 0x14 /* 20 */ 272 #define LDAP_INVALID_SYNTAX 0x15 /* 21 */ 273 274 #define LDAP_NO_SUCH_OBJECT 0x20 /* 32 */ 275 #define LDAP_ALIAS_PROBLEM 0x21 /* 33 */ 276 #define LDAP_INVALID_DN_SYNTAX 0x22 /* 34 */ 277 #define LDAP_IS_LEAF 0x23 /* 35 (not used in LDAPv3) */ 278 #define LDAP_ALIAS_DEREF_PROBLEM 0x24 /* 36 */ 279 280 #define NAME_ERROR(n) ((n & 0xf0) == 0x20) 281 282 #define LDAP_INAPPROPRIATE_AUTH 0x30 /* 48 */ 283 #define LDAP_INVALID_CREDENTIALS 0x31 /* 49 */ 284 #define LDAP_INSUFFICIENT_ACCESS 0x32 /* 50 */ 285 #define LDAP_BUSY 0x33 /* 51 */ 286 #define LDAP_UNAVAILABLE 0x34 /* 52 */ 287 #define LDAP_UNWILLING_TO_PERFORM 0x35 /* 53 */ 288 #define LDAP_LOOP_DETECT 0x36 /* 54 */ 289 290 #define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */ 291 #define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */ 292 293 #define LDAP_NAMING_VIOLATION 0x40 /* 64 */ 294 #define LDAP_OBJECT_CLASS_VIOLATION 0x41 /* 65 */ 295 #define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 /* 66 */ 296 #define LDAP_NOT_ALLOWED_ON_RDN 0x43 /* 67 */ 297 #define LDAP_ALREADY_EXISTS 0x44 /* 68 */ 298 #define LDAP_NO_OBJECT_CLASS_MODS 0x45 /* 69 */ 299 #define LDAP_RESULTS_TOO_LARGE 0x46 /* 70 - CLDAP */ 300 #define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 /* 71 */ 301 302 #define LDAP_OTHER 0x50 /* 80 */ 303 #define LDAP_SERVER_DOWN 0x51 /* 81 */ 304 #define LDAP_LOCAL_ERROR 0x52 /* 82 */ 305 #define LDAP_ENCODING_ERROR 0x53 /* 83 */ 306 #define LDAP_DECODING_ERROR 0x54 /* 84 */ 307 #define LDAP_TIMEOUT 0x55 /* 85 */ 308 #define LDAP_AUTH_UNKNOWN 0x56 /* 86 */ 309 #define LDAP_FILTER_ERROR 0x57 /* 87 */ 310 #define LDAP_USER_CANCELLED 0x58 /* 88 */ 311 #define LDAP_PARAM_ERROR 0x59 /* 89 */ 312 #define LDAP_NO_MEMORY 0x5a /* 90 */ 313 #define LDAP_CONNECT_ERROR 0x5b /* 91 */ 314 #define LDAP_NOT_SUPPORTED 0x5c /* 92 - LDAPv3 */ 315 #define LDAP_CONTROL_NOT_FOUND 0x5d /* 93 - LDAPv3 */ 316 #define LDAP_NO_RESULTS_RETURNED 0x5e /* 94 - LDAPv3 */ 317 #define LDAP_MORE_RESULTS_TO_RETURN 0x5f /* 95 - LDAPv3 */ 318 #define LDAP_CLIENT_LOOP 0x60 /* 96 - LDAPv3 */ 319 #define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 /* 97 - LDAPv3 */ 320 321 /* 322 * LDAPv3 unsolicited notification messages we know about 323 */ 324 #define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036" 325 326 /* 327 * LDAPv3 server controls we know about 328 */ 329 #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" 330 #define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" 331 #define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" 332 #define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3" 333 #define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7" 334 #define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" 335 #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" 336 #define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" 337 /* version 1 */ 338 #define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" 339 /* version 2 */ 340 341 #ifdef _SOLARIS_SDK 342 /* 343 * Simple Page control OID 344 */ 345 #define LDAP_CONTROL_SIMPLE_PAGE "1.2.840.113556.1.4.319" 346 347 /* 348 * Begin LDAP Display Template Definitions 349 */ 350 #define LDAP_TEMPLATE_VERSION 1 351 352 /* 353 * general types of items (confined to most significant byte) 354 */ 355 #define LDAP_SYN_TYPE_TEXT 0x01000000L 356 #define LDAP_SYN_TYPE_IMAGE 0x02000000L 357 #define LDAP_SYN_TYPE_BOOLEAN 0x04000000L 358 #define LDAP_SYN_TYPE_BUTTON 0x08000000L 359 #define LDAP_SYN_TYPE_ACTION 0x10000000L 360 361 /* 362 * syntax options (confined to second most significant byte) 363 */ 364 #define LDAP_SYN_OPT_DEFER 0x00010000L 365 366 /* 367 * display template item syntax ids (defined by common agreement) 368 * these are the valid values for the ti_syntaxid of the tmplitem 369 * struct (defined below). A general type is encoded in the 370 * most-significant 8 bits, and some options are encoded in the next 371 * 8 bits. The lower 16 bits are reserved for the distinct types. 372 */ 373 #define LDAP_SYN_CASEIGNORESTR (1 | LDAP_SYN_TYPE_TEXT) 374 #define LDAP_SYN_MULTILINESTR (2 | LDAP_SYN_TYPE_TEXT) 375 #define LDAP_SYN_DN (3 | LDAP_SYN_TYPE_TEXT) 376 #define LDAP_SYN_BOOLEAN (4 | LDAP_SYN_TYPE_BOOLEAN) 377 #define LDAP_SYN_JPEGIMAGE (5 | LDAP_SYN_TYPE_IMAGE) 378 #define LDAP_SYN_JPEGBUTTON (6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER) 379 #define LDAP_SYN_FAXIMAGE (7 | LDAP_SYN_TYPE_IMAGE) 380 #define LDAP_SYN_FAXBUTTON (8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER) 381 #define LDAP_SYN_AUDIOBUTTON (9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER) 382 #define LDAP_SYN_TIME (10 | LDAP_SYN_TYPE_TEXT) 383 #define LDAP_SYN_DATE (11 | LDAP_SYN_TYPE_TEXT) 384 #define LDAP_SYN_LABELEDURL (12 | LDAP_SYN_TYPE_TEXT) 385 #define LDAP_SYN_SEARCHACTION (13 | LDAP_SYN_TYPE_ACTION) 386 #define LDAP_SYN_LINKACTION (14 | LDAP_SYN_TYPE_ACTION) 387 #define LDAP_SYN_ADDDNACTION (15 | LDAP_SYN_TYPE_ACTION) 388 #define LDAP_SYN_VERIFYDNACTION (16 | LDAP_SYN_TYPE_ACTION) 389 #define LDAP_SYN_RFC822ADDR (17 | LDAP_SYN_TYPE_TEXT) 390 391 /* 392 * handy macros 393 */ 394 #define LDAP_GET_SYN_TYPE(syid) ((syid) & 0xFF000000UL) 395 #define LDAP_GET_SYN_OPTIONS(syid) ((syid) & 0x00FF0000UL) 396 397 398 /* 399 * display options for output routines (used by entry2text and friends) 400 */ 401 /* 402 * use calculated label width (based on length of longest label in 403 * template) instead of contant width 404 */ 405 #define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L 406 #define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L 407 408 /* 409 * perform search actions (applies to ldap_entry2text_search only) 410 */ 411 #define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L 412 413 /* 414 * include additional info. relevant to "non leaf" entries only 415 * used by ldap_entry2html and ldap_entry2html_search to include "Browse" 416 * and "Move Up" HREFs 417 */ 418 #define LDAP_DISP_OPT_NONLEAF 0x00000004L 419 420 /* 421 * display template item options (may not apply to all types) 422 * if this bit is set in ti_options, it applies. 423 */ 424 #define LDAP_DITEM_OPT_READONLY 0x00000001L 425 #define LDAP_DITEM_OPT_SORTVALUES 0x00000002L 426 #define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004L 427 #define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L 428 #define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010L 429 #define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L /* booleans only */ 430 431 #endif /* _SOLARIS_SDK */ 432 433 /* Authentication request and response controls */ 434 #define LDAP_CONTROL_AUTH_REQUEST "2.16.840.1.113730.3.4.16" 435 #define LDAP_CONTROL_AUTH_RESPONSE "2.16.840.1.113730.3.4.15" 436 437 /* Password information sent back to client */ 438 #define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4" 439 #define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5" 440 441 442 /* 443 * Client controls we know about 444 */ 445 #define LDAP_CONTROL_REFERRALS "1.2.840.113556.1.4.616" 446 447 448 /* 449 * LDAP_API macro definition: 450 */ 451 #ifndef LDAP_API 452 #define LDAP_API(rt) rt 453 #endif /* LDAP_API */ 454 455 #ifdef _SOLARIS_SDK 456 /* Simple Page Control functions for Solaris SDK */ 457 int ldap_create_page_control(LDAP *ld, unsigned int pagesize, 458 struct berval *cookie, char isCritical, LDAPControl **output); 459 int ldap_parse_page_control(LDAP *ld, LDAPControl **controls, 460 unsigned int *totalcount, struct berval **cookie); 461 462 /* CRAM-MD5 functions */ 463 int ldap_sasl_cram_md5_bind_s(LDAP *ld, char *dn, 464 struct berval *cred, LDAPControl **serverctrls, 465 LDAPControl **clientctrls); 466 /* DIGEST-MD5 Function */ 467 int ldap_x_sasl_digest_md5_bind_s(LDAP *ld, char *dn, 468 struct berval *cred, LDAPControl **serverctrls, 469 LDAPControl **clientctrls); 470 int ldap_x_sasl_digest_md5_bind(LDAP *ld, char *dn, 471 struct berval *cred, LDAPControl **serverctrls, 472 LDAPControl **clientctrls, struct timeval *timeout, 473 LDAPMessage **result); 474 475 #endif /* _SOLARIS_SDK */ 476 477 LDAP_API(LDAP *) LDAP_CALL ldap_open(const char *host, int port); 478 LDAP_API(LDAP *) LDAP_CALL ldap_init(const char *defhost, int defport); 479 int LDAP_CALL ldap_set_option(LDAP *ld, int option, 480 const void *optdata); 481 int LDAP_CALL ldap_get_option(LDAP *ld, int option, void *optdata); 482 int LDAP_CALL ldap_unbind(LDAP *ld); 483 int LDAP_CALL ldap_unbind_s(LDAP *ld); 484 485 /* 486 * perform ldap operations and obtain results 487 */ 488 int LDAP_CALL ldap_abandon(LDAP *ld, int msgid); 489 int LDAP_CALL ldap_add(LDAP *ld, const char *dn, LDAPMod **attrs); 490 int LDAP_CALL ldap_add_s(LDAP *ld, const char *dn, LDAPMod **attrs); 491 int LDAP_CALL ldap_simple_bind(LDAP *ld, const char *who, 492 const char *passwd); 493 int LDAP_CALL ldap_simple_bind_s(LDAP *ld, const char *who, 494 const char *passwd); 495 int LDAP_CALL ldap_modify(LDAP *ld, const char *dn, LDAPMod **mods); 496 int LDAP_CALL ldap_modify_s(LDAP *ld, const char *dn, 497 LDAPMod **mods); 498 int LDAP_CALL ldap_modrdn(LDAP *ld, const char *dn, 499 const char *newrdn); 500 int LDAP_CALL ldap_modrdn_s(LDAP *ld, const char *dn, 501 const char *newrdn); 502 503 /* The following 2 functions are deprecated */ 504 int LDAP_CALL ldap_modrdn2(LDAP *ld, const char *dn, 505 const char *newrdn, int deleteoldrdn); 506 int LDAP_CALL ldap_modrdn2_s(LDAP *ld, const char *dn, 507 const char *newrdn, int deleteoldrdn); 508 509 int LDAP_CALL ldap_compare(LDAP *ld, const char *dn, 510 const char *attr, const char *value); 511 int LDAP_CALL ldap_compare_s(LDAP *ld, const char *dn, 512 const char *attr, const char *value); 513 int LDAP_CALL ldap_delete(LDAP *ld, const char *dn); 514 int LDAP_CALL ldap_delete_s(LDAP *ld, const char *dn); 515 int LDAP_CALL ldap_search(LDAP *ld, const char *base, int scope, 516 const char *filter, char **attrs, int attrsonly); 517 int LDAP_CALL ldap_search_s(LDAP *ld, const char *base, int scope, 518 const char *filter, char **attrs, int attrsonly, LDAPMessage **res); 519 int LDAP_CALL ldap_search_st(LDAP *ld, const char *base, int scope, 520 const char *filter, char **attrs, int attrsonly, 521 struct timeval *timeout, LDAPMessage **res); 522 int LDAP_CALL ldap_result(LDAP *ld, int msgid, int all, 523 struct timeval *timeout, LDAPMessage **result); 524 int LDAP_CALL ldap_msgfree(LDAPMessage *lm); 525 int LDAP_CALL ldap_msgid(LDAPMessage *lm); 526 int LDAP_CALL ldap_msgtype(LDAPMessage *lm); 527 528 529 /* 530 * Routines to parse/deal with results and errors returned 531 */ 532 int LDAP_CALL ldap_result2error(LDAP *ld, LDAPMessage *r, 533 int freeit); 534 char *LDAP_CALL ldap_err2string(int err); 535 LDAP_API(void) LDAP_CALL ldap_perror(LDAP *ld, const char *s); 536 LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_entry(LDAP *ld, 537 LDAPMessage *chain); 538 LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_entry(LDAP *ld, 539 LDAPMessage *entry); 540 int LDAP_CALL ldap_count_entries(LDAP *ld, LDAPMessage *chain); 541 char *LDAP_CALL ldap_get_dn(LDAP *ld, LDAPMessage *entry); 542 char *LDAP_CALL ldap_dn2ufn(const char *dn); 543 char **LDAP_CALL ldap_explode_dn(const char *dn, 544 const int notypes); 545 char **LDAP_CALL ldap_explode_rdn(const char *rdn, 546 const int notypes); 547 char *LDAP_CALL ldap_first_attribute(LDAP *ld, LDAPMessage *entry, 548 BerElement **ber); 549 char *LDAP_CALL ldap_next_attribute(LDAP *ld, LDAPMessage *entry, 550 BerElement *ber); 551 552 /* The following function is deprecated */ 553 LDAP_API(void) LDAP_CALL ldap_ber_free(BerElement *ber, int freebuf); 554 555 char **LDAP_CALL ldap_get_values(LDAP *ld, LDAPMessage *entry, 556 const char *target); 557 struct berval **LDAP_CALL ldap_get_values_len(LDAP *ld, 558 LDAPMessage *entry, const char *target); 559 int LDAP_CALL ldap_count_values(char **vals); 560 int LDAP_CALL ldap_count_values_len(struct berval **vals); 561 LDAP_API(void) LDAP_CALL ldap_value_free(char **vals); 562 LDAP_API(void) LDAP_CALL ldap_value_free_len(struct berval **vals); 563 LDAP_API(void) LDAP_CALL ldap_memfree(void *p); 564 565 566 /* 567 * LDAPv3 extended operation calls 568 */ 569 /* 570 * Note: all of the new asynchronous calls return an LDAP error code, 571 * not a message id. A message id is returned via the int *msgidp 572 * parameter (usually the last parameter) if appropriate. 573 */ 574 int LDAP_CALL ldap_abandon_ext(LDAP *ld, int msgid, 575 LDAPControl **serverctrls, LDAPControl **clientctrls); 576 int LDAP_CALL ldap_add_ext(LDAP *ld, const char *dn, LDAPMod **attrs, 577 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 578 int LDAP_CALL ldap_add_ext_s(LDAP *ld, const char *dn, 579 LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls); 580 int LDAP_CALL ldap_sasl_bind(LDAP *ld, const char *dn, 581 const char *mechanism, const struct berval *cred, 582 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 583 int LDAP_CALL ldap_sasl_bind_s(LDAP *ld, const char *dn, 584 const char *mechanism, const struct berval *cred, 585 LDAPControl **serverctrls, LDAPControl **clientctrls, 586 struct berval **servercredp); 587 int LDAP_CALL ldap_modify_ext(LDAP *ld, const char *dn, 588 LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls, 589 int *msgidp); 590 int LDAP_CALL ldap_modify_ext_s(LDAP *ld, const char *dn, 591 LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls); 592 int LDAP_CALL ldap_rename(LDAP *ld, const char *dn, 593 const char *newrdn, const char *newparent, int deleteoldrdn, 594 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 595 int LDAP_CALL ldap_rename_s(LDAP *ld, const char *dn, 596 const char *newrdn, const char *newparent, int deleteoldrdn, 597 LDAPControl **serverctrls, LDAPControl **clientctrls); 598 int LDAP_CALL ldap_compare_ext(LDAP *ld, const char *dn, 599 const char *attr, const struct berval *bvalue, 600 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 601 int LDAP_CALL ldap_compare_ext_s(LDAP *ld, const char *dn, 602 const char *attr, const struct berval *bvalue, 603 LDAPControl **serverctrls, LDAPControl **clientctrls); 604 int LDAP_CALL ldap_delete_ext(LDAP *ld, const char *dn, 605 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 606 int LDAP_CALL ldap_delete_ext_s(LDAP *ld, const char *dn, 607 LDAPControl **serverctrls, LDAPControl **clientctrls); 608 int LDAP_CALL ldap_search_ext(LDAP *ld, const char *base, 609 int scope, const char *filter, char **attrs, int attrsonly, 610 LDAPControl **serverctrls, LDAPControl **clientctrls, 611 struct timeval *timeoutp, int sizelimit, int *msgidp); 612 int LDAP_CALL ldap_search_ext_s(LDAP *ld, const char *base, 613 int scope, const char *filter, char **attrs, int attrsonly, 614 LDAPControl **serverctrls, LDAPControl **clientctrls, 615 struct timeval *timeoutp, int sizelimit, LDAPMessage **res); 616 int LDAP_CALL ldap_extended_operation(LDAP *ld, 617 const char *requestoid, const struct berval *requestdata, 618 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 619 int LDAP_CALL ldap_extended_operation_s(LDAP *ld, 620 const char *requestoid, const struct berval *requestdata, 621 LDAPControl **serverctrls, LDAPControl **clientctrls, 622 char **retoidp, struct berval **retdatap); 623 int LDAP_CALL ldap_unbind_ext(LDAP *ld, LDAPControl **serverctrls, 624 LDAPControl **clientctrls); 625 626 627 /* 628 * LDAPv3 extended parsing / result handling calls 629 */ 630 int LDAP_CALL ldap_parse_sasl_bind_result(LDAP *ld, 631 LDAPMessage *res, struct berval **servercredp, int freeit); 632 int LDAP_CALL ldap_parse_result(LDAP *ld, LDAPMessage *res, 633 int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp, 634 LDAPControl ***serverctrlsp, int freeit); 635 int LDAP_CALL ldap_parse_extended_result(LDAP *ld, LDAPMessage *res, 636 char **retoidp, struct berval **retdatap, int freeit); 637 LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_message(LDAP *ld, 638 LDAPMessage *res); 639 LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_message(LDAP *ld, 640 LDAPMessage *msg); 641 int LDAP_CALL ldap_count_messages(LDAP *ld, LDAPMessage *res); 642 LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_reference(LDAP *ld, 643 LDAPMessage *res); 644 LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_reference(LDAP *ld, 645 LDAPMessage *ref); 646 int LDAP_CALL ldap_count_references(LDAP *ld, LDAPMessage *res); 647 int LDAP_CALL ldap_parse_reference(LDAP *ld, LDAPMessage *ref, 648 char ***referralsp, LDAPControl ***serverctrlsp, int freeit); 649 int LDAP_CALL ldap_get_entry_controls(LDAP *ld, LDAPMessage *entry, 650 LDAPControl ***serverctrlsp); 651 LDAP_API(void) LDAP_CALL ldap_control_free(LDAPControl *ctrl); 652 LDAP_API(void) LDAP_CALL ldap_controls_free(LDAPControl **ctrls); 653 654 #ifdef _SOLARIS_SDK 655 char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res); 656 #endif 657 658 659 /* End of core standard C LDAP API definitions */ 660 661 /* 662 * Server side sorting of search results (an LDAPv3 extension -- 663 * LDAP_API_FEATURE_SERVER_SIDE_SORT) 664 */ 665 typedef struct LDAPsortkey { /* structure for a sort-key */ 666 char *sk_attrtype; 667 char *sk_matchruleoid; 668 int sk_reverseorder; 669 } LDAPsortkey; 670 671 int LDAP_CALL ldap_create_sort_control(LDAP *ld, 672 LDAPsortkey **sortKeyList, const char ctl_iscritical, 673 LDAPControl **ctrlp); 674 int LDAP_CALL ldap_parse_sort_control(LDAP *ld, 675 LDAPControl **ctrls, unsigned long *result, char **attribute); 676 677 LDAP_API(void) LDAP_CALL ldap_free_sort_keylist(LDAPsortkey **sortKeyList); 678 int LDAP_CALL ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, 679 const char *string_rep); 680 681 682 /* 683 * Virtual list view (an LDAPv3 extension -- LDAP_API_FEATURE_VIRTUAL_LIST_VIEW) 684 */ 685 /* 686 * structure that describes a VirtualListViewRequest control. 687 * note that ldvlist_index and ldvlist_size are only relevant to 688 * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL. 689 */ 690 typedef struct ldapvirtuallist { 691 unsigned long ldvlist_before_count; /* # entries before target */ 692 unsigned long ldvlist_after_count; /* # entries after target */ 693 char *ldvlist_attrvalue; /* jump to this value */ 694 unsigned long ldvlist_index; /* list offset */ 695 unsigned long ldvlist_size; /* number of items in vlist */ 696 void *ldvlist_extradata; /* for use by application */ 697 } LDAPVirtualList; 698 699 /* 700 * VLV functions: 701 */ 702 int LDAP_CALL ldap_create_virtuallist_control(LDAP *ld, 703 LDAPVirtualList *ldvlistp, LDAPControl **ctrlp); 704 705 int LDAP_CALL ldap_parse_virtuallist_control(LDAP *ld, 706 LDAPControl **ctrls, unsigned long *target_posp, 707 unsigned long *list_sizep, int *errcodep); 708 709 710 /* 711 * Routines for creating persistent search controls and for handling 712 * "entry changed notification" controls (an LDAPv3 extension -- 713 * LDAP_API_FEATURE_PERSISTENT_SEARCH) 714 */ 715 #define LDAP_CHANGETYPE_ADD 1 716 #define LDAP_CHANGETYPE_DELETE 2 717 #define LDAP_CHANGETYPE_MODIFY 4 718 #define LDAP_CHANGETYPE_MODDN 8 719 #define LDAP_CHANGETYPE_ANY (1|2|4|8) 720 int LDAP_CALL ldap_create_persistentsearch_control(LDAP *ld, 721 int changetypes, int changesonly, int return_echg_ctls, 722 char ctl_iscritical, LDAPControl **ctrlp); 723 int LDAP_CALL ldap_parse_entrychange_control(LDAP *ld, 724 LDAPControl **ctrls, int *chgtypep, char **prevdnp, 725 int *chgnumpresentp, ber_int_t *chgnump); 726 727 728 /* 729 * Routines for creating Proxied Authorization controls (an LDAPv3 730 * extension -- LDAP_API_FEATURE_PROXY_AUTHORIZATION) 731 * ldap_create_proxyauth_control() is for the old (version 1) control. 732 * ldap_create_proxiedauth_control() is for the newer (version 2) control. 733 * Version 1 is supported by iPlanet Directory Server 4.1 and later. 734 * Version 2 is supported by iPlanet Directory Server 5.0 and later. 735 */ 736 int LDAP_CALL ldap_create_proxyauth_control(LDAP *ld, 737 const char *dn, const char ctl_iscritical, LDAPControl **ctrlp); 738 int LDAP_CALL ldap_create_proxiedauth_control(LDAP *ld, 739 const char *authzid, LDAPControl **ctrlp); 740 741 742 /* 743 * Functions to get and set LDAP error information (API extension -- 744 * LDAP_API_FEATURE_X_LDERRNO ) 745 */ 746 int LDAP_CALL ldap_get_lderrno(LDAP *ld, char **m, char **s); 747 int LDAP_CALL ldap_set_lderrno(LDAP *ld, int e, char *m, char *s); 748 749 750 /* 751 * LDAP URL functions and definitions (an API extension -- 752 * LDAP_API_FEATURE_X_URL_FUNCTIONS) 753 */ 754 /* 755 * types for ldap URL handling 756 */ 757 typedef struct ldap_url_desc { 758 char *lud_host; 759 int lud_port; 760 char *lud_dn; 761 char **lud_attrs; 762 int lud_scope; 763 char *lud_filter; 764 unsigned long lud_options; 765 #define LDAP_URL_OPT_SECURE 0x01 766 char *lud_string; /* for internal use only */ 767 } LDAPURLDesc; 768 769 #define NULLLDAPURLDESC ((LDAPURLDesc *)NULL) 770 771 /* 772 * possible errors returned by ldap_url_parse() 773 */ 774 #define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */ 775 #define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */ 776 #define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */ 777 #define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */ 778 #define LDAP_URL_ERR_PARAM 5 /* bad parameter to an URL function */ 779 #define LDAP_URL_ERR_HOSTPORT 6 /* URL hostcode is invalid */ 780 781 /* 782 * URL functions: 783 */ 784 int LDAP_CALL ldap_is_ldap_url(const char *url); 785 int LDAP_CALL ldap_url_parse(const char *url, LDAPURLDesc **ludpp); 786 int LDAP_CALL ldap_url_parse_nodn(const char *url, LDAPURLDesc **ludpp); 787 LDAP_API(void) LDAP_CALL ldap_free_urldesc(LDAPURLDesc *ludp); 788 int LDAP_CALL ldap_url_search(LDAP *ld, const char *url, 789 int attrsonly); 790 int LDAP_CALL ldap_url_search_s(LDAP *ld, const char *url, 791 int attrsonly, LDAPMessage **res); 792 int LDAP_CALL ldap_url_search_st(LDAP *ld, const char *url, 793 int attrsonly, struct timeval *timeout, LDAPMessage **res); 794 795 #ifdef _SOLARIS_SDK 796 /* 797 * Additional URL functions plus Character set, Search Preference 798 * and Display Template functions moved from internal header files 799 */ 800 801 /* 802 * URL functions 803 */ 804 char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs, 805 char *scope, char *filter); 806 char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts); 807 808 /* 809 * Character set functions 810 */ 811 #ifdef STR_TRANSLATION 812 void ldap_set_string_translators(LDAP *ld, 813 BERTranslateProc encode_proc, BERTranslateProc decode_proc); 814 int ldap_translate_from_t61(LDAP *ld, char **bufp, 815 unsigned long *lenp, int free_input); 816 int ldap_translate_to_t61(LDAP *ld, char **bufp, 817 unsigned long *lenp, int free_input); 818 void ldap_enable_translation(LDAP *ld, LDAPMessage *entry, 819 int enable); 820 #ifdef LDAP_CHARSET_8859 821 int ldap_t61_to_8859(char **bufp, unsigned long *buflenp, 822 int free_input); 823 int ldap_8859_to_t61(char **bufp, unsigned long *buflenp, 824 int free_input); 825 #endif /* LDAP_CHARSET_8859 */ 826 #endif /* STR_TRANSLATION */ 827 828 /* 829 * Display Temple functions/structures 830 */ 831 /* 832 * display template item structure 833 */ 834 struct ldap_tmplitem { 835 unsigned long ti_syntaxid; 836 unsigned long ti_options; 837 char *ti_attrname; 838 char *ti_label; 839 char **ti_args; 840 struct ldap_tmplitem *ti_next_in_row; 841 struct ldap_tmplitem *ti_next_in_col; 842 void *ti_appdata; 843 }; 844 845 #define NULLTMPLITEM ((struct ldap_tmplitem *)0) 846 847 #define LDAP_SET_TMPLITEM_APPDATA(ti, datap) \ 848 (ti)->ti_appdata = (void *)(datap) 849 850 #define LDAP_GET_TMPLITEM_APPDATA(ti, type) \ 851 (type)((ti)->ti_appdata) 852 853 #define LDAP_IS_TMPLITEM_OPTION_SET(ti, option) \ 854 (((ti)->ti_options & option) != 0) 855 856 /* 857 * object class array structure 858 */ 859 struct ldap_oclist { 860 char **oc_objclasses; 861 struct ldap_oclist *oc_next; 862 }; 863 864 #define NULLOCLIST ((struct ldap_oclist *)0) 865 866 867 /* 868 * add defaults list 869 */ 870 struct ldap_adddeflist { 871 int ad_source; 872 #define LDAP_ADSRC_CONSTANTVALUE 1 873 #define LDAP_ADSRC_ADDERSDN 2 874 char *ad_attrname; 875 char *ad_value; 876 struct ldap_adddeflist *ad_next; 877 }; 878 879 #define NULLADLIST ((struct ldap_adddeflist *)0) 880 881 882 /* 883 * display template global options 884 * if this bit is set in dt_options, it applies. 885 */ 886 /* 887 * users should be allowed to try to add objects of these entries 888 */ 889 #define LDAP_DTMPL_OPT_ADDABLE 0x00000001L 890 891 /* 892 * users should be allowed to do "modify RDN" operation of these entries 893 */ 894 #define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L 895 896 /* 897 * this template is an alternate view, not a primary view 898 */ 899 #define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L 900 901 902 /* 903 * display template structure 904 */ 905 struct ldap_disptmpl { 906 char *dt_name; 907 char *dt_pluralname; 908 char *dt_iconname; 909 unsigned long dt_options; 910 char *dt_authattrname; 911 char *dt_defrdnattrname; 912 char *dt_defaddlocation; 913 struct ldap_oclist *dt_oclist; 914 struct ldap_adddeflist *dt_adddeflist; 915 struct ldap_tmplitem *dt_items; 916 void *dt_appdata; 917 struct ldap_disptmpl *dt_next; 918 }; 919 920 #define NULLDISPTMPL ((struct ldap_disptmpl *)0) 921 922 #define LDAP_SET_DISPTMPL_APPDATA(dt, datap) \ 923 (dt)->dt_appdata = (void *)(datap) 924 925 #define LDAP_GET_DISPTMPL_APPDATA(dt, type) \ 926 (type)((dt)->dt_appdata) 927 928 #define LDAP_IS_DISPTMPL_OPTION_SET(dt, option) \ 929 (((dt)->dt_options & option) != 0) 930 931 #define LDAP_TMPL_ERR_VERSION 1 932 #define LDAP_TMPL_ERR_MEM 2 933 #define LDAP_TMPL_ERR_SYNTAX 3 934 #define LDAP_TMPL_ERR_FILE 4 935 936 /* 937 * buffer size needed for entry2text and vals2text 938 */ 939 #define LDAP_DTMPL_BUFSIZ 8192 940 941 typedef int (*writeptype)(void *writeparm, char *p, int len); 942 943 LDAP_API(int) 944 LDAP_CALL 945 ldap_init_templates(char *file, struct ldap_disptmpl **tmpllistp); 946 947 LDAP_API(int) 948 LDAP_CALL 949 ldap_init_templates_buf(char *buf, long buflen, 950 struct ldap_disptmpl **tmpllistp); 951 952 LDAP_API(void) 953 LDAP_CALL 954 ldap_free_templates(struct ldap_disptmpl *tmpllist); 955 956 LDAP_API(struct ldap_disptmpl *) 957 LDAP_CALL 958 ldap_first_disptmpl(struct ldap_disptmpl *tmpllist); 959 960 LDAP_API(struct ldap_disptmpl *) 961 LDAP_CALL 962 ldap_next_disptmpl(struct ldap_disptmpl *tmpllist, 963 struct ldap_disptmpl *tmpl); 964 965 LDAP_API(struct ldap_disptmpl *) 966 LDAP_CALL 967 ldap_name2template(char *name, struct ldap_disptmpl *tmpllist); 968 969 LDAP_API(struct ldap_disptmpl *) 970 LDAP_CALL 971 ldap_oc2template(char **oclist, struct ldap_disptmpl *tmpllist); 972 973 LDAP_API(char **) 974 LDAP_CALL 975 ldap_tmplattrs(struct ldap_disptmpl *tmpl, char **includeattrs, int exclude, 976 unsigned long syntaxmask); 977 978 LDAP_API(struct ldap_tmplitem *) 979 LDAP_CALL 980 ldap_first_tmplrow(struct ldap_disptmpl *tmpl); 981 982 LDAP_API(struct ldap_tmplitem *) 983 LDAP_CALL 984 ldap_next_tmplrow(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row); 985 986 LDAP_API(struct ldap_tmplitem *) 987 LDAP_CALL 988 ldap_first_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row); 989 990 LDAP_API(struct ldap_tmplitem *) 991 LDAP_CALL 992 ldap_next_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, 993 struct ldap_tmplitem *col); 994 995 LDAP_API(int) 996 LDAP_CALL 997 ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry, 998 struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, 999 writeptype writeproc, void *writeparm, char *eol, int rdncount, 1000 unsigned long opts); 1001 1002 LDAP_API(int) 1003 LDAP_CALL 1004 ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label, int labelwidth, 1005 unsigned long syntaxid, writeptype writeproc, void *writeparm, 1006 char *eol, int rdncount); 1007 1008 LDAP_API(int) 1009 LDAP_CALL 1010 ldap_entry2text_search(LDAP *ld, char *dn, char *base, LDAPMessage *entry, 1011 struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, 1012 writeptype writeproc, void *writeparm, char *eol, int rdncount, 1013 unsigned long opts); 1014 1015 LDAP_API(int) 1016 LDAP_CALL 1017 ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry, 1018 struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, 1019 writeptype writeproc, void *writeparm, char *eol, int rdncount, 1020 unsigned long opts, char *urlprefix, char *base); 1021 1022 LDAP_API(int) 1023 LDAP_CALL 1024 ldap_vals2html(LDAP *ld, char *buf, char **vals, char *label, int labelwidth, 1025 unsigned long syntaxid, writeptype writeproc, void *writeparm, 1026 char *eol, int rdncount, char *urlprefix); 1027 1028 LDAP_API(int) 1029 LDAP_CALL 1030 ldap_entry2html_search(LDAP *ld, char *dn, char *base, LDAPMessage *entry, 1031 struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, 1032 writeptype writeproc, void *writeparm, char *eol, int rdncount, 1033 unsigned long opts, char *urlprefix); 1034 1035 /* 1036 * Search Preference Definitions 1037 */ 1038 1039 struct ldap_searchattr { 1040 char *sa_attrlabel; 1041 char *sa_attr; 1042 /* max 32 matchtypes for now */ 1043 unsigned long sa_matchtypebitmap; 1044 char *sa_selectattr; 1045 char *sa_selecttext; 1046 struct ldap_searchattr *sa_next; 1047 }; 1048 1049 struct ldap_searchmatch { 1050 char *sm_matchprompt; 1051 char *sm_filter; 1052 struct ldap_searchmatch *sm_next; 1053 }; 1054 1055 struct ldap_searchobj { 1056 char *so_objtypeprompt; 1057 unsigned long so_options; 1058 char *so_prompt; 1059 short so_defaultscope; 1060 char *so_filterprefix; 1061 char *so_filtertag; 1062 char *so_defaultselectattr; 1063 char *so_defaultselecttext; 1064 struct ldap_searchattr *so_salist; 1065 struct ldap_searchmatch *so_smlist; 1066 struct ldap_searchobj *so_next; 1067 }; 1068 1069 #define NULLSEARCHOBJ ((struct ldap_searchobj *)0) 1070 1071 /* 1072 * global search object options 1073 */ 1074 #define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001 1075 1076 #define LDAP_IS_SEARCHOBJ_OPTION_SET(so, option) \ 1077 (((so)->so_options & option) != 0) 1078 1079 #define LDAP_SEARCHPREF_VERSION_ZERO 0 1080 #define LDAP_SEARCHPREF_VERSION 1 1081 1082 #define LDAP_SEARCHPREF_ERR_VERSION 1 1083 #define LDAP_SEARCHPREF_ERR_MEM 2 1084 #define LDAP_SEARCHPREF_ERR_SYNTAX 3 1085 #define LDAP_SEARCHPREF_ERR_FILE 4 1086 1087 LDAP_API(int) 1088 LDAP_CALL 1089 ldap_init_searchprefs(char *file, struct ldap_searchobj **solistp); 1090 1091 LDAP_API(int) 1092 LDAP_CALL 1093 ldap_init_searchprefs_buf(char *buf, long buflen, 1094 struct ldap_searchobj **solistp); 1095 1096 LDAP_API(void) 1097 LDAP_CALL 1098 ldap_free_searchprefs(struct ldap_searchobj *solist); 1099 1100 LDAP_API(struct ldap_searchobj *) 1101 LDAP_CALL 1102 ldap_first_searchobj(struct ldap_searchobj *solist); 1103 1104 LDAP_API(struct ldap_searchobj *) 1105 LDAP_CALL 1106 ldap_next_searchobj(struct ldap_searchobj *sollist, 1107 struct ldap_searchobj *so); 1108 1109 /* 1110 * specific LDAP instantiations of BER types we know about 1111 */ 1112 1113 /* general stuff */ 1114 #define LDAP_TAG_MESSAGE 0x30 /* tag is 16 + constructed bit */ 1115 #define LDAP_TAG_MSGID 0x02 /* INTEGER */ 1116 #define LDAP_TAG_CONTROLS 0xa0 /* context specific + constructed + 0 */ 1117 #define LDAP_TAG_REFERRAL 0xa3 /* context specific + constructed + 3 */ 1118 #define LDAP_TAG_NEWSUPERIOR 0x80 /* context specific + primitive + 0 */ 1119 #define LDAP_TAG_SASL_RES_CREDS 0x87 /* context specific + primitive + 7 */ 1120 #define LDAP_TAG_VLV_BY_INDEX 0xa0 /* context specific + constructed + 0 */ 1121 #define LDAP_TAG_VLV_BY_VALUE 0x81 /* context specific + primitive + 1 */ 1122 /* tag for sort control */ 1123 #define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive + 0 */ 1124 #define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive + 1 */ 1125 #define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive + 0 */ 1126 1127 /* possible operations a client can invoke */ 1128 #define LDAP_REQ_BIND 0x60 /* application + constructed + 0 */ 1129 #define LDAP_REQ_UNBIND 0x42 /* application + primitive + 2 */ 1130 #define LDAP_REQ_SEARCH 0x63 /* application + constructed + 3 */ 1131 #define LDAP_REQ_MODIFY 0x66 /* application + constructed + 6 */ 1132 #define LDAP_REQ_ADD 0x68 /* application + constructed + 8 */ 1133 #define LDAP_REQ_DELETE 0x4a /* application + primitive + 10 */ 1134 #define LDAP_REQ_MODRDN 0x6c /* application + constructed + 12 */ 1135 #define LDAP_REQ_MODDN 0x6c /* application + constructed + 12 */ 1136 #define LDAP_REQ_RENAME 0x6c /* application + constructed + 12 */ 1137 #define LDAP_REQ_COMPARE 0x6e /* application + constructed + 14 */ 1138 #define LDAP_REQ_ABANDON 0x50 /* application + primitive + 16 */ 1139 #define LDAP_REQ_EXTENDED 0x77 /* application + constructed + 23 */ 1140 1141 /* U-M LDAP release 3.0 compatibility stuff */ 1142 #define LDAP_REQ_UNBIND_30 0x62 1143 #define LDAP_REQ_DELETE_30 0x6a 1144 #define LDAP_REQ_ABANDON_30 0x70 1145 1146 /* U-M LDAP 3.0 compatibility auth methods */ 1147 #define LDAP_AUTH_SIMPLE_30 0xa0 /* context specific + constructed */ 1148 #define LDAP_AUTH_KRBV41_30 0xa1 /* context specific + constructed */ 1149 #define LDAP_AUTH_KRBV42_30 0xa2 /* context specific + constructed */ 1150 1151 /* filter types */ 1152 #define LDAP_FILTER_AND 0xa0 /* context specific + constructed + 0 */ 1153 #define LDAP_FILTER_OR 0xa1 /* context specific + constructed + 1 */ 1154 #define LDAP_FILTER_NOT 0xa2 /* context specific + constructed + 2 */ 1155 #define LDAP_FILTER_EQUALITY 0xa3 /* context specific + constructed + 3 */ 1156 #define LDAP_FILTER_SUBSTRINGS 0xa4 /* context specific + constructed + 4 */ 1157 #define LDAP_FILTER_GE 0xa5 /* context specific + constructed + 5 */ 1158 #define LDAP_FILTER_LE 0xa6 /* context specific + constructed + 6 */ 1159 #define LDAP_FILTER_PRESENT 0x87 /* context specific + primitive + 7 */ 1160 #define LDAP_FILTER_APPROX 0xa8 /* context specific + constructed + 8 */ 1161 #define LDAP_FILTER_EXTENDED 0xa9 /* context specific + constructed + 0 */ 1162 1163 /* U-M LDAP 3.0 compatibility filter types */ 1164 #define LDAP_FILTER_PRESENT_30 0xa7 /* context specific + constructed */ 1165 1166 /* substring filter component types */ 1167 #define LDAP_SUBSTRING_INITIAL 0x80 /* context specific + primitive + 0 */ 1168 #define LDAP_SUBSTRING_ANY 0x81 /* context specific + primitive + 1 */ 1169 #define LDAP_SUBSTRING_FINAL 0x82 /* context specific + primitive + 2 */ 1170 1171 /* U-M LDAP 3.0 compatibility substring filter component types */ 1172 #define LDAP_SUBSTRING_INITIAL_30 0xa0 /* context specific */ 1173 #define LDAP_SUBSTRING_ANY_30 0xa1 /* context specific */ 1174 #define LDAP_SUBSTRING_FINAL_30 0xa2 /* context specific */ 1175 1176 #endif /* _SOLARIS_SDK */ 1177 1178 /* 1179 * Function to dispose of an array of LDAPMod structures (an API extension). 1180 * Warning: don't use this unless the mods array was allocated using the 1181 * same memory allocator as is being used by libldap. 1182 */ 1183 LDAP_API(void) LDAP_CALL ldap_mods_free(LDAPMod **mods, int freemods); 1184 1185 /* 1186 * Preferred language and get_lang_values (an API extension -- 1187 * LDAP_API_FEATURE_X_GETLANGVALUES) 1188 * 1189 * The following two APIs are deprecated 1190 */ 1191 1192 char **LDAP_CALL ldap_get_lang_values(LDAP *ld, LDAPMessage *entry, 1193 const char *target, char **type); 1194 struct berval **LDAP_CALL ldap_get_lang_values_len(LDAP *ld, 1195 LDAPMessage *entry, const char *target, char **type); 1196 1197 1198 /* 1199 * Rebind callback function (an API extension) 1200 */ 1201 #define LDAP_OPT_REBIND_FN 0x06 /* 6 - API extension */ 1202 #define LDAP_OPT_REBIND_ARG 0x07 /* 7 - API extension */ 1203 typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)(LDAP *ld, 1204 char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg); 1205 LDAP_API(void) LDAP_CALL ldap_set_rebind_proc(LDAP *ld, 1206 LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg); 1207 1208 /* 1209 * Thread function callbacks (an API extension -- 1210 * LDAP_API_FEATURE_X_THREAD_FUNCTIONS). 1211 */ 1212 #define LDAP_OPT_THREAD_FN_PTRS 0x05 /* 5 - API extension */ 1213 1214 /* 1215 * Thread callback functions: 1216 */ 1217 typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)(void); 1218 typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)(void *m); 1219 typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)(void *m); 1220 typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)(void *m); 1221 typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)(void); 1222 typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)(int e); 1223 typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)( 1224 char **matchedp, char **errmsgp, void *arg); 1225 typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)(int err, 1226 char *matched, char *errmsg, void *arg); 1227 1228 /* 1229 * Structure to hold thread function pointers: 1230 */ 1231 struct ldap_thread_fns { 1232 LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc; 1233 LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free; 1234 LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock; 1235 LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock; 1236 LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno; 1237 LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno; 1238 LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno; 1239 LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno; 1240 void *ltf_lderrno_arg; 1241 }; 1242 1243 /* 1244 * Client side sorting of entries (an API extension -- 1245 * LDAP_API_FEATURE_X_CLIENT_SIDE_SORT) 1246 */ 1247 /* 1248 * Client side sorting callback functions: 1249 */ 1250 typedef const struct berval *(LDAP_C LDAP_CALLBACK 1251 LDAP_KEYGEN_CALLBACK)(void *arg, LDAP *ld, LDAPMessage *entry); 1252 typedef int (LDAP_C LDAP_CALLBACK 1253 LDAP_KEYCMP_CALLBACK)(void *arg, const struct berval *, 1254 const struct berval *); 1255 typedef void (LDAP_C LDAP_CALLBACK 1256 LDAP_KEYFREE_CALLBACK)(void *arg, const struct berval *); 1257 typedef int (LDAP_C LDAP_CALLBACK 1258 LDAP_CMP_CALLBACK)(const char *val1, const char *val2); 1259 typedef int (LDAP_C LDAP_CALLBACK 1260 LDAP_VALCMP_CALLBACK)(const char **val1p, const char **val2p); 1261 1262 /* 1263 * Client side sorting functions: 1264 */ 1265 int LDAP_CALL ldap_multisort_entries(LDAP *ld, LDAPMessage **chain, 1266 char **attr, LDAP_CMP_CALLBACK *cmp); 1267 int LDAP_CALL ldap_sort_entries(LDAP *ld, LDAPMessage **chain, 1268 char *attr, LDAP_CMP_CALLBACK *cmp); 1269 int LDAP_CALL ldap_sort_values(LDAP *ld, char **vals, 1270 LDAP_VALCMP_CALLBACK *cmp); 1271 int LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp(const char **a, 1272 const char **b); 1273 1274 1275 /* 1276 * Filter functions and definitions (an API extension -- 1277 * LDAP_API_FEATURE_X_FILTER_FUNCTIONS) 1278 */ 1279 /* 1280 * Structures, constants, and types for filter utility routines: 1281 */ 1282 typedef struct ldap_filt_info { 1283 char *lfi_filter; 1284 char *lfi_desc; 1285 int lfi_scope; /* LDAP_SCOPE_BASE, etc */ 1286 int lfi_isexact; /* exact match filter? */ 1287 struct ldap_filt_info *lfi_next; 1288 } LDAPFiltInfo; 1289 1290 #define LDAP_FILT_MAXSIZ 1024 1291 1292 typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */ 1293 typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */ 1294 1295 /* 1296 * Filter utility functions: 1297 */ 1298 LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter(char *fname); 1299 LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf(char *buf, 1300 ssize_t buflen); 1301 LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter(LDAPFiltDesc *lfdp, 1302 char *tagpat, char *value); 1303 LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter(LDAPFiltDesc *lfdp); 1304 int LDAP_CALL ldap_set_filter_additions(LDAPFiltDesc *lfdp, 1305 char *prefix, char *suffix); 1306 int LDAP_CALL ldap_create_filter(char *buf, unsigned long buflen, 1307 char *pattern, char *prefix, char *suffix, char *attr, 1308 char *value, char **valwords); 1309 LDAP_API(void) LDAP_CALL ldap_getfilter_free(LDAPFiltDesc *lfdp); 1310 1311 1312 /* 1313 * Friendly mapping structure and routines (an API extension) 1314 */ 1315 typedef struct friendly { 1316 char *f_unfriendly; 1317 char *f_friendly; 1318 } *FriendlyMap; 1319 char *LDAP_CALL ldap_friendly_name(char *filename, char *name, 1320 FriendlyMap *map); 1321 LDAP_API(void) LDAP_CALL ldap_free_friendlymap(FriendlyMap *map); 1322 1323 1324 /* 1325 * In Memory Cache (an API extension -- LDAP_API_FEATURE_X_MEMCACHE) 1326 */ 1327 typedef struct ldapmemcache LDAPMemCache; /* opaque in-memory cache handle */ 1328 1329 int LDAP_CALL ldap_memcache_init(unsigned long ttl, 1330 unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns, 1331 LDAPMemCache **cachep); 1332 int LDAP_CALL ldap_memcache_set(LDAP *ld, LDAPMemCache *cache); 1333 int LDAP_CALL ldap_memcache_get(LDAP *ld, LDAPMemCache **cachep); 1334 LDAP_API(void) LDAP_CALL ldap_memcache_flush(LDAPMemCache *cache, char *dn, 1335 int scope); 1336 LDAP_API(void) LDAP_CALL ldap_memcache_destroy(LDAPMemCache *cache); 1337 LDAP_API(void) LDAP_CALL ldap_memcache_update(LDAPMemCache *cache); 1338 1339 /* 1340 * Server reconnect (an API extension). 1341 */ 1342 #define LDAP_OPT_RECONNECT 0x62 /* 98 - API extension */ 1343 1344 /* 1345 * Asynchronous I/O (an API extension). 1346 */ 1347 /* 1348 * This option enables completely asynchronous IO. It works by using ioctl() 1349 * on the fd, (or tlook()) 1350 */ 1351 #define LDAP_OPT_ASYNC_CONNECT 0x63 /* 99 - API extension */ 1352 1353 /* 1354 * I/O function callbacks option (an API extension -- 1355 * LDAP_API_FEATURE_X_IO_FUNCTIONS). 1356 * Use of the extended I/O functions instead is recommended; see above. 1357 */ 1358 #define LDAP_OPT_IO_FN_PTRS 0x0B /* 11 - API extension */ 1359 1360 /* 1361 * Extended I/O function callbacks option (an API extension -- 1362 * LDAP_API_FEATURE_X_EXTIO_FUNCTIONS). 1363 */ 1364 #define LDAP_X_OPT_EXTIO_FN_PTRS (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F00) 1365 /* 0x4000 + 0x0F00 = 0x4F00 = 20224 - API extension */ 1366 1367 1368 1369 /* 1370 * generalized bind 1371 */ 1372 /* 1373 * Authentication methods: 1374 */ 1375 #define LDAP_AUTH_NONE 0x00 1376 #define LDAP_AUTH_SIMPLE 0x80 1377 #define LDAP_AUTH_SASL 0xa3 1378 int LDAP_CALL ldap_bind(LDAP *ld, const char *who, 1379 const char *passwd, int authmethod); 1380 int LDAP_CALL ldap_bind_s(LDAP *ld, const char *who, 1381 const char *cred, int method); 1382 1383 /* 1384 * experimental DN format support 1385 */ 1386 char **LDAP_CALL ldap_explode_dns(const char *dn); 1387 int LDAP_CALL ldap_is_dns_dn(const char *dn); 1388 1389 #ifdef _SOLARIS_SDK 1390 char *ldap_dns_to_dn(char *dns_name, int *nameparts); 1391 #endif 1392 1393 1394 /* 1395 * user friendly naming/searching routines 1396 */ 1397 typedef int (LDAP_C LDAP_CALLBACK LDAP_CANCELPROC_CALLBACK)(void *cl); 1398 int LDAP_CALL ldap_ufn_search_c(LDAP *ld, char *ufn, 1399 char **attrs, int attrsonly, LDAPMessage **res, 1400 LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm); 1401 int LDAP_CALL ldap_ufn_search_ct(LDAP *ld, char *ufn, 1402 char **attrs, int attrsonly, LDAPMessage **res, 1403 LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, 1404 char *tag1, char *tag2, char *tag3); 1405 int LDAP_CALL ldap_ufn_search_s(LDAP *ld, char *ufn, 1406 char **attrs, int attrsonly, LDAPMessage **res); 1407 LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_ufn_setfilter(LDAP *ld, char *fname); 1408 LDAP_API(void) LDAP_CALL ldap_ufn_setprefix(LDAP *ld, char *prefix); 1409 int LDAP_C ldap_ufn_timeout(void *tvparam); 1410 1411 /* 1412 * functions and definitions that have been replaced by new improved ones 1413 */ 1414 /* 1415 * Use ldap_get_option() with LDAP_OPT_API_INFO and an LDAPAPIInfo structure 1416 * instead of ldap_version(). The use of this API is deprecated. 1417 */ 1418 typedef struct _LDAPVersion { 1419 int sdk_version; /* Version of the SDK, * 100 */ 1420 int protocol_version; /* Highest protocol version supported, * 100 */ 1421 int SSL_version; /* SSL version if this SDK supports it, * 100 */ 1422 int security_level; /* highest level available */ 1423 int reserved[4]; 1424 } LDAPVersion; 1425 #define LDAP_SECURITY_NONE 0 1426 int LDAP_CALL ldap_version(LDAPVersion *ver); 1427 1428 /* use ldap_create_filter() instead of ldap_build_filter() */ 1429 LDAP_API(void) LDAP_CALL ldap_build_filter(char *buf, size_t buflen, 1430 char *pattern, char *prefix, char *suffix, char *attr, 1431 char *value, char **valwords); 1432 /* use ldap_set_filter_additions() instead of ldap_setfilteraffixes() */ 1433 LDAP_API(void) LDAP_CALL ldap_setfilteraffixes(LDAPFiltDesc *lfdp, 1434 char *prefix, char *suffix); 1435 1436 /* older result types a server can return -- use LDAP_RES_MODDN instead */ 1437 #define LDAP_RES_MODRDN LDAP_RES_MODDN 1438 #define LDAP_RES_RENAME LDAP_RES_MODDN 1439 1440 /* older error messages */ 1441 #define LDAP_AUTH_METHOD_NOT_SUPPORTED LDAP_STRONG_AUTH_NOT_SUPPORTED 1442 1443 /* end of unsupported functions */ 1444 1445 #ifdef _SOLARIS_SDK 1446 1447 /* SSL Functions */ 1448 1449 /* 1450 * these three defines resolve the SSL strength 1451 * setting auth weak, diables all cert checking 1452 * the CNCHECK tests for the man in the middle hack 1453 */ 1454 #define LDAPSSL_AUTH_WEAK 0 1455 #define LDAPSSL_AUTH_CERT 1 1456 #define LDAPSSL_AUTH_CNCHECK 2 1457 1458 /* 1459 * Initialize LDAP library for SSL 1460 */ 1461 LDAP * LDAP_CALL ldapssl_init(const char *defhost, int defport, 1462 int defsecure); 1463 1464 /* 1465 * Install I/O routines to make SSL over LDAP possible. 1466 * Use this after ldap_init() or just use ldapssl_init() instead. 1467 */ 1468 int LDAP_CALL ldapssl_install_routines(LDAP *ld); 1469 1470 1471 /* 1472 * The next three functions initialize the security code for SSL 1473 * The first one ldapssl_client_init() does initialization for SSL only 1474 * The next one supports ldapssl_clientauth_init() intializes security 1475 * for SSL for client authentication. The third function initializes 1476 * security for doing SSL with client authentication, and PKCS, that is, 1477 * the third function initializes the security module database(secmod.db). 1478 * The parameters are as follows: 1479 * const char *certdbpath - path to the cert file. This can be a shortcut 1480 * to the directory name, if so cert7.db will be postfixed to the string. 1481 * void *certdbhandle - Normally this is NULL. This memory will need 1482 * to be freed. 1483 * int needkeydb - boolean. Must be ! = 0 if client Authentification 1484 * is required 1485 * char *keydbpath - path to the key database. This can be a shortcut 1486 * to the directory name, if so key3.db will be postfixed to the string. 1487 * void *keydbhandle - Normally this is NULL, This memory will need 1488 * to be freed 1489 * int needsecmoddb - boolean. Must be ! = 0 to assure that the correct 1490 * security module is loaded into memory 1491 * char *secmodpath - path to the secmod. This can be a shortcut to the 1492 * directory name, if so secmod.db will be postfixed to the string. 1493 * 1494 * These three functions are mutually exclusive. You can only call 1495 * one. This means that, for a given process, you must call the 1496 * appropriate initialization function for the life of the process. 1497 */ 1498 1499 1500 /* 1501 * Initialize the secure parts (Security and SSL) of the runtime for use 1502 * by a client application. This is only called once. 1503 */ 1504 int LDAP_CALL ldapssl_client_init( 1505 const char *certdbpath, void *certdbhandle); 1506 1507 /* 1508 * Initialize the secure parts (Security and SSL) of the runtime for use 1509 * by a client application that may want to do SSL client authentication. 1510 */ 1511 int LDAP_CALL ldapssl_clientauth_init( 1512 const char *certdbpath, void *certdbhandle, 1513 const int needkeydb, const char *keydbpath, void *keydbhandle); 1514 1515 /* 1516 * Initialize the secure parts (Security and SSL) of the runtime for use 1517 * by a client application that may want to do SSL client authentication. 1518 */ 1519 int LDAP_CALL ldapssl_advclientauth_init( 1520 const char *certdbpath, void *certdbhandle, 1521 const int needkeydb, const char *keydbpath, void *keydbhandle, 1522 const int needsecmoddb, const char *secmoddbpath, 1523 const int sslstrength); 1524 1525 /* 1526 * get a meaningful error string back from the security library 1527 * this function should be called, if ldap_err2string doesn't 1528 * identify the error code. 1529 */ 1530 const char *LDAP_CALL ldapssl_err2string(const int prerrno); 1531 1532 /* 1533 * Enable SSL client authentication on the given ld. 1534 */ 1535 int LDAP_CALL ldapssl_enable_clientauth(LDAP *ld, char *keynickname, 1536 char *keypasswd, char *certnickname); 1537 1538 typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_TOKEN_CALLBACK) 1539 (void *context, char **tokenname); 1540 typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_PIN_CALLBACK) 1541 (void *context, const char *tokenname, char **tokenpin); 1542 typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTPATH_CALLBACK) 1543 (void *context, char **certpath); 1544 typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_KEYPATH_CALLBACK) 1545 (void *context, char **keypath); 1546 typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_MODPATH_CALLBACK) 1547 (void *context, char **modulepath); 1548 typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTNAME_CALLBACK) 1549 (void *context, char **certname); 1550 typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK) 1551 (void *context, char **filename); 1552 1553 #define PKCS_STRUCTURE_ID 1 1554 struct ldapssl_pkcs_fns { 1555 int local_structure_id; 1556 void *local_data; 1557 LDAP_PKCS_GET_CERTPATH_CALLBACK *pkcs_getcertpath; 1558 LDAP_PKCS_GET_CERTNAME_CALLBACK *pkcs_getcertname; 1559 LDAP_PKCS_GET_KEYPATH_CALLBACK *pkcs_getkeypath; 1560 LDAP_PKCS_GET_MODPATH_CALLBACK *pkcs_getmodpath; 1561 LDAP_PKCS_GET_PIN_CALLBACK *pkcs_getpin; 1562 LDAP_PKCS_GET_TOKEN_CALLBACK *pkcs_gettokenname; 1563 LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK *pkcs_getdonglefilename; 1564 1565 }; 1566 1567 1568 int LDAP_CALL ldapssl_pkcs_init(const struct ldapssl_pkcs_fns *pfns); 1569 1570 /* end of SSL functions */ 1571 #endif /* _SOLARIS_SDK */ 1572 1573 /* SASL options */ 1574 #define LDAP_OPT_X_SASL_MECH 0x6100 1575 #define LDAP_OPT_X_SASL_REALM 0x6101 1576 #define LDAP_OPT_X_SASL_AUTHCID 0x6102 1577 #define LDAP_OPT_X_SASL_AUTHZID 0x6103 1578 #define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */ 1579 #define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */ 1580 #define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */ 1581 #define LDAP_OPT_X_SASL_SSF_MIN 0x6107 1582 #define LDAP_OPT_X_SASL_SSF_MAX 0x6108 1583 #define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109 1584 1585 /* 1586 * ldap_interactive_bind_s Interaction flags 1587 * Interactive: prompt always - REQUIRED 1588 */ 1589 #define LDAP_SASL_INTERACTIVE 1U 1590 1591 /* 1592 * V3 SASL Interaction Function Callback Prototype 1593 * when using SASL, interact is pointer to sasl_interact_t 1594 * should likely passed in a control (and provided controls) 1595 */ 1596 typedef int (LDAP_SASL_INTERACT_PROC) 1597 (LDAP *ld, unsigned flags, void* defaults, void *interact); 1598 1599 int LDAP_CALL ldap_sasl_interactive_bind_s(LDAP *ld, const char *dn, 1600 const char *saslMechanism, LDAPControl **serverControls, 1601 LDAPControl **clientControls, unsigned flags, 1602 LDAP_SASL_INTERACT_PROC *proc, void *defaults); 1603 1604 #ifdef __cplusplus 1605 } 1606 #endif 1607 1608 #endif /* _LDAP_H */ 1609