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