1 /* 2 * Copyright (c) 2001 by Sun Microsystems, Inc. 3 * All rights reserved. 4 */ 5 6 /* 7 * Copyright (c) 1990 Regents of the University of Michigan. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms are permitted 11 * provided that this notice is preserved and that due credit is given 12 * to the University of Michigan at Ann Arbor. The name of the University 13 * may not be used to endorse or promote products derived from this 14 * software without specific prior written permission. This software 15 * is provided ``as is'' without express or implied warranty. 16 */ 17 18 #ifndef _LDAP_H 19 #define _LDAP_H 20 21 #pragma ident "%Z%%M% %I% %E% SMI" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 #ifdef LDAP_SSL 28 #include <security/ssl.h> 29 #endif /* LDAP_SSL */ 30 31 32 #include <pthread.h> 33 34 #ifdef LDAP_SSL 35 #define SSL_LDAP_PORT 636 36 #endif 37 38 #if !defined(NEEDPROTOS) && defined(__STDC__) 39 #define NEEDPROTOS 1 40 #endif 41 42 #define LDAP_API_VERSION 2004 43 #define LDAP_VERSION_MIN 2 44 #define LDAP_VERSION_MAX 3 45 #define LDAP_VENDOR_NAME "Sun Microsystems Inc." 46 #define LDAP_VENDOR_VERSION 400 47 48 #define LDAP_PORT 389 49 #define LDAP_VERSION1 1 50 #define LDAP_VERSION2 2 51 #define LDAP_VERSION3 3 52 #define LDAP_VERSION LDAP_VERSION2 53 54 /* OPTIONS to use with ldap_set_option and ldap_get_option */ 55 #define LDAP_OPT_API_INFO 0x00 56 #define LDAP_OPT_DESC 0x01 /* Use of this option is depricated */ 57 /* int, control how aliases are handled during search */ 58 #define LDAP_OPT_DEREF 0x02 59 /* Deref values */ 60 #define LDAP_DEREF_NEVER 0x00 61 #define LDAP_DEREF_SEARCHING 0x01 62 #define LDAP_DEREF_FINDING 0x02 63 #define LDAP_DEREF_ALWAYS 0x03 64 65 #define LDAP_OPT_SIZELIMIT 0x03 /* int, size limit of a search */ 66 #define LDAP_OPT_TIMELIMIT 0x04 /* int, time limit of a search */ 67 #define LDAP_OPT_REBIND_FN 0x06 /* Use of this options is depricated */ 68 #define LDAP_OPT_REBIND_ARG 0x07 /* Use of this options is depricated */ 69 #define LDAP_OPT_REFERRALS 0x08 /* ON/OFF, chase referrals */ 70 #define LDAP_OPT_RESTART 0x09 /* ON/OFF, restart if EINTR occurs */ 71 /* int, protocol version, default 2 */ 72 #define LDAP_OPT_PROTOCOL_VERSION 0x11 73 /* List of ldap controls to be sent with each request */ 74 #define LDAP_OPT_SERVER_CONTROLS 0x12 75 /* List of ldap controls that affect the session */ 76 #define LDAP_OPT_CLIENT_CONTROLS 0x13 77 #define LDAP_OPT_API_FEATURE_INFO 0x15 78 /* The hostname of the default ldap server */ 79 #define LDAP_OPT_HOST_NAME 0x30 80 /* The code of the most recent ldap error that occured for this session */ 81 #define LDAP_OPT_ERROR_NUMBER 0x31 82 /* The message returned with the most recent ldap error */ 83 #define LDAP_OPT_ERROR_STRING 0x32 84 /* The Matching DN in case of a naming error */ 85 #define LDAP_OPT_MATCHED_DN 0x33 86 #define LDAP_OPT_ERROR_MATCHED 0x33 /* Use of this options is depricated */ 87 88 /* The timeout while trying to connect to a server */ 89 #define LDAP_X_OPT_CONNECT_TIMEOUT 0x4F01 90 #define LDAP_X_IO_TIMEOUT_NO_WAIT 0 91 #define LDAP_X_IO_TIMEOUT_NO_TIMEOUT -1 92 93 /* The Filter List Desc used by UFN functions */ 94 /* #define LDAP_OPT_FILTERDESC 0x80 */ 95 /* For on/off options */ 96 #define LDAP_OPT_ON ((void *)1) 97 #define LDAP_OPT_OFF ((void *)0) 98 99 /* Used for NO limitation is TIMELIMIT or SIZELIMIT */ 100 #define LDAP_NO_LIMIT 0 101 102 #define LDAP_MAX_ATTR_LEN 100 103 #define LDAP_RETURN_NO_ATTR "1.1" 104 #define LDAP_RETURN_ALL_ATTR "" 105 #define LDAP_RETURN_ALL_ATTR_OPS "*" 106 107 /* Begin LDAP Display Template Definitions */ 108 #define LDAP_TEMPLATE_VERSION 1 109 110 /* 111 * general types of items (confined to most significant byte) 112 */ 113 #define LDAP_SYN_TYPE_TEXT 0x01000000 114 #define LDAP_SYN_TYPE_IMAGE 0x02000000 115 #define LDAP_SYN_TYPE_BOOLEAN 0x04000000 116 #define LDAP_SYN_TYPE_BUTTON 0x08000000 117 #define LDAP_SYN_TYPE_ACTION 0x10000000 118 119 /* 120 * syntax options (confined to second most significant byte) 121 */ 122 #define LDAP_SYN_OPT_DEFER 0x00010000 123 124 125 /* 126 * display template item syntax ids (defined by common agreement) 127 * these are the valid values for the ti_syntaxid of the tmplitem 128 * struct (defined below). A general type is encoded in the 129 * most-significant 8 bits, and some options are encoded in the next 130 * 8 bits. The lower 16 bits are reserved for the distinct types. 131 */ 132 #define LDAP_SYN_CASEIGNORESTR (1 | LDAP_SYN_TYPE_TEXT) 133 #define LDAP_SYN_MULTILINESTR (2 | LDAP_SYN_TYPE_TEXT) 134 #define LDAP_SYN_DN (3 | LDAP_SYN_TYPE_TEXT) 135 #define LDAP_SYN_BOOLEAN (4 | LDAP_SYN_TYPE_BOOLEAN) 136 #define LDAP_SYN_JPEGIMAGE (5 | LDAP_SYN_TYPE_IMAGE) 137 #define LDAP_SYN_JPEGBUTTON (6 | LDAP_SYN_TYPE_BUTTON | \ 138 LDAP_SYN_OPT_DEFER) 139 #define LDAP_SYN_FAXIMAGE (7 | LDAP_SYN_TYPE_IMAGE) 140 #define LDAP_SYN_FAXBUTTON (8 | LDAP_SYN_TYPE_BUTTON | \ 141 LDAP_SYN_OPT_DEFER) 142 #define LDAP_SYN_AUDIOBUTTON (9 | LDAP_SYN_TYPE_BUTTON | \ 143 LDAP_SYN_OPT_DEFER) 144 #define LDAP_SYN_TIME (10 | LDAP_SYN_TYPE_TEXT) 145 #define LDAP_SYN_DATE (11 | LDAP_SYN_TYPE_TEXT) 146 #define LDAP_SYN_LABELEDURL (12 | LDAP_SYN_TYPE_TEXT) 147 #define LDAP_SYN_SEARCHACTION (13 | LDAP_SYN_TYPE_ACTION) 148 #define LDAP_SYN_LINKACTION (14 | LDAP_SYN_TYPE_ACTION) 149 #define LDAP_SYN_ADDDNACTION (15 | LDAP_SYN_TYPE_ACTION) 150 #define LDAP_SYN_VERIFYDNACTION (16 | LDAP_SYN_TYPE_ACTION) 151 #define LDAP_SYN_RFC822ADDR (17 | LDAP_SYN_TYPE_TEXT) 152 #ifdef SUN 153 #define LDAP_SYN_PROTECTED (18 | LDAP_SYN_TYPE_TEXT) 154 #endif 155 156 /* 157 * handy macros 158 */ 159 #define LDAP_GET_SYN_TYPE(syid) ((syid) & 0xFF000000) 160 #define LDAP_GET_SYN_OPTIONS(syid) ((syid) & 0x00FF0000) 161 162 /* 163 * display options for output routines (used by entry2text and friends) 164 */ 165 /* 166 * use calculated label width (based on length of longest label in 167 * template) instead of contant width 168 */ 169 #define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001 170 #define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002 171 172 /* 173 * perform search actions (applies to ldap_entry2text_search only) 174 */ 175 #define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002 176 177 /* 178 * include additional info. relevant to "non leaf" entries only 179 * used by ldap_entry2html and ldap_entry2html_search to include "Browse" 180 * and "Move Up" HREFs 181 */ 182 #define LDAP_DISP_OPT_NONLEAF 0x00000004 183 184 185 /* 186 * display template item options (may not apply to all types) 187 * if this bit is set in ti_options, it applies. 188 */ 189 #define LDAP_DITEM_OPT_READONLY 0x00000001 190 #define LDAP_DITEM_OPT_SORTVALUES 0x00000002 191 #define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004 192 #define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008 193 #define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010 194 #define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020 /* booleans only */ 195 196 197 /* 198 * LDAP API Information structure 199 */ 200 typedef struct ldapapiinfo { 201 int ldapai_info_version; /* version of this struct (1) */ 202 int ldapai_api_version; /* revision of API supported */ 203 int ldapai_protocol_version; /* highest LDAP version supported */ 204 char **ldapai_extensions; /* names of API extensions */ 205 char *ldapai_vendor_name; /* name of supplier */ 206 int ldapai_vendor_version; /* supplier-specific version * 100 */ 207 } LDAPAPIInfo; 208 #define LDAP_API_INFO_VERSION 1 209 210 211 /* 212 * LDAP API Feature Information 213 */ 214 typedef struct ldap_apifeature_info { 215 int ldapaif_info_version; /* version of this struct (1) */ 216 char *ldapaif_name; /* name of supported feature */ 217 int ldapaif_version; /* revision of supported feature */ 218 } LDAPAPIFeatureInfo; 219 #define LDAP_FEATURE_INFO_VERSION 1 220 221 222 /* 223 * display template item structure 224 */ 225 struct ldap_tmplitem { 226 unsigned int ti_syntaxid; 227 unsigned int ti_options; 228 char *ti_attrname; 229 char *ti_label; 230 char **ti_args; 231 struct ldap_tmplitem *ti_next_in_row; 232 struct ldap_tmplitem *ti_next_in_col; 233 void *ti_appdata; 234 }; 235 236 237 #define NULLTMPLITEM ((struct ldap_tmplitem *)0) 238 239 #define LDAP_SET_TMPLITEM_APPDATA(ti, datap) \ 240 (ti)->ti_appdata = (void *)(datap) 241 242 #define LDAP_GET_TMPLITEM_APPDATA(ti, type) \ 243 (type)((ti)->ti_appdata) 244 245 246 #define LDAP_IS_TMPLITEM_OPTION_SET(ti, option) \ 247 (((ti)->ti_options & option) != 0) 248 249 250 /* 251 * object class array structure 252 */ 253 struct ldap_oclist { 254 char **oc_objclasses; 255 struct ldap_oclist *oc_next; 256 }; 257 258 #define NULLOCLIST ((struct ldap_oclist *)0) 259 260 261 /* 262 * add defaults list 263 */ 264 struct ldap_adddeflist { 265 int ad_source; 266 #define LDAP_ADSRC_CONSTANTVALUE 1 267 #define LDAP_ADSRC_ADDERSDN 2 268 char *ad_attrname; 269 char *ad_value; 270 struct ldap_adddeflist *ad_next; 271 }; 272 273 #define NULLADLIST ((struct ldap_adddeflist *)0) 274 275 276 /* 277 * display template global options 278 * if this bit is set in dt_options, it applies. 279 */ 280 /* 281 * users should be allowed to try to add objects of these entries 282 */ 283 #define LDAP_DTMPL_OPT_ADDABLE 0x00000001 284 285 /* 286 * users should be allowed to do "modify RDN" operation of these entries 287 */ 288 #define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002 289 290 /* 291 * this template is an alternate view, not a primary view 292 */ 293 #define LDAP_DTMPL_OPT_ALTVIEW 0x00000004 294 295 296 /* 297 * display template structure 298 */ 299 struct ldap_disptmpl { 300 char *dt_name; 301 char *dt_pluralname; 302 char *dt_iconname; 303 unsigned int dt_options; 304 char *dt_authattrname; 305 char *dt_defrdnattrname; 306 char *dt_defaddlocation; 307 struct ldap_oclist *dt_oclist; 308 struct ldap_adddeflist *dt_adddeflist; 309 struct ldap_tmplitem *dt_items; 310 void *dt_appdata; 311 struct ldap_disptmpl *dt_next; 312 }; 313 314 #define NULLDISPTMPL ((struct ldap_disptmpl *)0) 315 316 #define LDAP_SET_DISPTMPL_APPDATA(dt, datap) \ 317 (dt)->dt_appdata = (void *)(datap) 318 319 #define LDAP_GET_DISPTMPL_APPDATA(dt, type) \ 320 (type)((dt)->dt_appdata) 321 322 #define LDAP_IS_DISPTMPL_OPTION_SET(dt, option) \ 323 (((dt)->dt_options & option) != 0) 324 325 #define LDAP_TMPL_ERR_VERSION 1 326 #define LDAP_TMPL_ERR_MEM 2 327 #define LDAP_TMPL_ERR_SYNTAX 3 328 #define LDAP_TMPL_ERR_FILE 4 329 330 /* 331 * buffer size needed for entry2text and vals2text 332 */ 333 #define LDAP_DTMPL_BUFSIZ 8192 334 335 /* END Display Template Definitions */ 336 337 /* BEGIN Search Prefrences Definitions */ 338 339 struct ldap_searchattr { 340 char *sa_attrlabel; 341 char *sa_attr; 342 /* max 32 matchtypes for now */ 343 unsigned int sa_matchtypebitmap; 344 char *sa_selectattr; 345 char *sa_selecttext; 346 struct ldap_searchattr *sa_next; 347 }; 348 349 struct ldap_searchmatch { 350 char *sm_matchprompt; 351 char *sm_filter; 352 struct ldap_searchmatch *sm_next; 353 }; 354 355 struct ldap_searchobj { 356 char *so_objtypeprompt; 357 unsigned int so_options; 358 char *so_prompt; 359 short so_defaultscope; 360 char *so_filterprefix; 361 char *so_filtertag; 362 char *so_defaultselectattr; 363 char *so_defaultselecttext; 364 struct ldap_searchattr *so_salist; 365 struct ldap_searchmatch *so_smlist; 366 struct ldap_searchobj *so_next; 367 }; 368 369 #define NULLSEARCHOBJ ((struct ldap_searchobj *)0) 370 371 /* 372 * global search object options 373 */ 374 #define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001 375 376 #define LDAP_IS_SEARCHOBJ_OPTION_SET(so, option) \ 377 (((so)->so_options & option) != 0) 378 379 #define LDAP_SEARCHPREF_VERSION_ZERO 0 380 #define LDAP_SEARCHPREF_VERSION 1 381 382 #define LDAP_SEARCHPREF_ERR_VERSION 1 383 #define LDAP_SEARCHPREF_ERR_MEM 2 384 #define LDAP_SEARCHPREF_ERR_SYNTAX 3 385 #define LDAP_SEARCHPREF_ERR_FILE 4 386 387 388 /* END Search Prefrences Definitions */ 389 390 /* 391 * Structure for LDAP modifications 392 */ 393 typedef struct ldapmod { 394 int mod_op; 395 #define LDAP_MOD_ADD 0x00 396 #define LDAP_MOD_DELETE 0x01 397 #define LDAP_MOD_REPLACE 0x02 398 #define LDAP_MOD_BVALUES 0x80 399 char *mod_type; 400 union { 401 char **modv_strvals; 402 struct berval **modv_bvals; 403 } mod_vals; 404 #define mod_values mod_vals.modv_strvals 405 #define mod_bvalues mod_vals.modv_bvals 406 /* 407 * The following field is commented out since no functions use it in 408 * the library and also not part of c-api draft. 409 */ 410 /* struct ldapmod *mod_next */ 411 } LDAPMod; 412 413 typedef struct ldap LDAP; /* Opaque LDAP connection handle */ 414 415 typedef struct ldapmsg LDAPMessage; /* Opaque Result / Entry handle */ 416 417 #define NULLMSG ((LDAPMessage *) NULL) 418 419 /* Call back to get info needed for re-bind */ 420 typedef int (LDAP_REBIND_FUNCTION)(LDAP *ld, char **dn, char **passwd, 421 int *authmethod, int freeit, void *extraArg); 422 423 /* 424 * structures for ldap getfilter routines 425 */ 426 427 typedef struct ldap_filt_info { 428 char *lfi_filter; 429 char *lfi_desc; 430 int lfi_scope; /* LDAP_SCOPE_BASE, etc */ 431 int lfi_isexact; /* exact match filter? */ 432 struct ldap_filt_info *lfi_next; 433 } LDAPFiltInfo; 434 435 436 #define LDAP_FILT_MAXSIZ 1024 437 438 typedef struct ldap_filt_list LDAPFiltList; 439 typedef struct ldap_filt_desc LDAPFiltDesc; 440 441 442 /* 443 * Simple Page control OID 444 */ 445 #define LDAP_CONTROL_SIMPLE_PAGE "1.2.840.113556.1.4.319" 446 447 /* 448 * Server Sort Control 449 */ 450 #define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" 451 #define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" 452 /* 453 * structure for a sort-key 454 */ 455 typedef struct LDAPsortkey { 456 char *sk_attrtype; 457 char *sk_matchruleoid; 458 int sk_reverseorder; 459 } LDAPsortkey; 460 461 /* 462 * Virtual List View (vlv) control 463 */ 464 #define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" 465 #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" 466 /* 467 * structure that describes a VirtualListViewRequest control. 468 * note that ldvlist_index and ldvlist_size are only relevant to 469 * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL. 470 */ 471 typedef struct ldapvirtuallist { 472 unsigned long ldvlist_before_count; /* # entries before target */ 473 unsigned long ldvlist_after_count; /* # entries after target */ 474 char *ldvlist_attrvalue; /* jump to this value */ 475 unsigned long ldvlist_index; /* list offset */ 476 unsigned long ldvlist_size; /* number of items in vlist */ 477 void *ldvlist_extradata; /* for use by application */ 478 } LDAPVirtualList; 479 480 /* 481 * ldapv3 LDAPControl 482 */ 483 typedef struct ldapcontrol 484 { 485 char *ldctl_oid; 486 /* 487 * the "ldctl_value" field of this structure used to be a pointer to 488 * struct berval. To make this structure compliant to the latest c-api 489 * draft, it is changed to "struct berval ldctl_value" 490 */ 491 struct berval ldctl_value; 492 char ldctl_iscritical; 493 } LDAPControl, *PLDAPControl; 494 495 /* 496 * specific LDAP instantiations of BER types we know about 497 */ 498 499 /* general stuff */ 500 #define LDAP_TAG_MESSAGE 0x30 /* tag is 16 + constructed bit */ 501 #define LDAP_TAG_MSGID 0x02 502 #define LDAP_TAG_CONTROL_LIST 0xA0 /* Context 0 + constructed */ 503 #define LDAP_TAG_REFERRAL 0xA3 /* Context 3 + constructed */ 504 #define LDAP_TAG_SASLCREDS 0x87 /* Context 7 + primitive */ 505 #define LDAP_TAG_AUTH_SIMPLE 0x80 /* Context 0 + primitive */ 506 #define LDAP_TAG_AUTH_SASL 0xA3 /* Context 3 + constructed */ 507 /* Tag for modrdn request */ 508 #define LDAP_TAG_NEWPARENT 0x80 /* Context 0 + primitive */ 509 /* Tags for Extensible filter match */ 510 #define LDAP_TAG_FEXT_RULE 0x81 /* Context 1 + primitive */ 511 #define LDAP_TAG_FEXT_TYPE 0x82 /* Context 2 + primitive */ 512 #define LDAP_TAG_FEXT_VAL 0x83 /* Context 3 + primitive */ 513 #define LDAP_TAG_FEXT_DN 0x84 /* Context 4 + primitive */ 514 /* tags for EXTENDED OPERATIONS */ 515 #define LDAP_TAG_EXT_NAME 0x80 /* Context 0 + primitive */ 516 #define LDAP_TAG_EXT_VAL 0x81 /* Context 1 + primitive */ 517 #define LDAP_TAG_EXT_RESPNAME 0x8a /* Context 10 + primitive */ 518 #define LDAP_TAG_EXT_RESPONSE 0x8b /* Context 11 + primitive */ 519 /* tags for Virtual List View control */ 520 #define LDAP_TAG_VLV_BY_INDEX 0xa0 /* context specific + constructed + 0 */ 521 #define LDAP_TAG_VLV_BY_VALUE 0x81 /* context specific + primitive + 1 */ 522 /* tag for sort control */ 523 #define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive */ 524 #define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive */ 525 #define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive */ 526 527 /* possible operations a client can invoke */ 528 #define LDAP_REQ_BIND 0x60 /* application + constructed */ 529 #define LDAP_REQ_UNBIND 0x42 /* application + primitive */ 530 #define LDAP_REQ_SEARCH 0x63 /* application + constructed */ 531 #define LDAP_REQ_MODIFY 0x66 /* application + constructed */ 532 #define LDAP_REQ_ADD 0x68 /* application + constructed */ 533 #define LDAP_REQ_DELETE 0x4a /* application + primitive */ 534 #define LDAP_REQ_MODRDN 0x6c /* application + constructed */ 535 #define LDAP_REQ_COMPARE 0x6e /* application + constructed */ 536 #define LDAP_REQ_ABANDON 0x50 /* application + primitive */ 537 /* New in ldapv3 application + constructed */ 538 #define LDAP_REQ_EXTENDED 0x77 539 /* version 3.0 compatibility stuff */ 540 #define LDAP_REQ_UNBIND_30 0x62 541 #define LDAP_REQ_DELETE_30 0x6a 542 #define LDAP_REQ_ABANDON_30 0x70 543 544 /* possible result types a server can return */ 545 #define LDAP_RES_BIND 0x61 /* application + constructed */ 546 #define LDAP_RES_SEARCH_ENTRY 0x64 /* application + constructed */ 547 /* new in ldapv3, application + constructed */ 548 #define LDAP_RES_SEARCH_REFERENCE 0x73 549 #define LDAP_RES_SEARCH_RESULT 0x65 /* application + constructed */ 550 #define LDAP_RES_MODIFY 0x67 /* application + constructed */ 551 #define LDAP_RES_ADD 0x69 /* application + constructed */ 552 #define LDAP_RES_DELETE 0x6b /* application + constructed */ 553 #define LDAP_RES_MODRDN 0x6d /* application + constructed */ 554 #define LDAP_RES_COMPARE 0x6f /* application + constructed */ 555 /* new in ldapv3, application + constructed */ 556 #define LDAP_RES_EXTENDED 0x78 557 #define LDAP_RES_ANY (-1) 558 559 /* authentication methods available */ 560 #define LDAP_AUTH_NONE 0x00 /* no authentication */ 561 #define LDAP_AUTH_SIMPLE 0x80 /* context specific + primitive */ 562 #define LDAP_AUTH_KRBV4 0xff /* means do both of the following */ 563 #define LDAP_AUTH_KRBV41 0x81 /* context specific + primitive */ 564 #define LDAP_AUTH_KRBV42 0x82 /* context specific + primitive */ 565 /* New with ldapv3 */ 566 #define LDAP_AUTH_SASL 0xa3 /* context specific + constructed */ 567 568 /* 3.0 compatibility auth methods */ 569 #define LDAP_AUTH_SIMPLE_30 0xa0 /* context specific + constructed */ 570 #define LDAP_AUTH_KRBV41_30 0xa1 /* context specific + constructed */ 571 #define LDAP_AUTH_KRBV42_30 0xa2 /* context specific + constructed */ 572 573 /* filter types */ 574 #define LDAP_FILTER_AND 0xa0 /* context specific + constructed */ 575 #define LDAP_FILTER_OR 0xa1 /* context specific + constructed */ 576 #define LDAP_FILTER_NOT 0xa2 /* context specific + constructed */ 577 #define LDAP_FILTER_EQUALITY 0xa3 /* context specific + constructed */ 578 #define LDAP_FILTER_SUBSTRINGS 0xa4 /* context specific + constructed */ 579 #define LDAP_FILTER_GE 0xa5 /* context specific + constructed */ 580 #define LDAP_FILTER_LE 0xa6 /* context specific + constructed */ 581 #define LDAP_FILTER_PRESENT 0x87 /* context specific + primitive */ 582 #define LDAP_FILTER_APPROX 0xa8 /* context specific + constructed */ 583 #define LDAP_FILTER_EXTENSIBLE 0xa9 /* context specific + constructed */ 584 585 /* 3.0 compatibility filter types */ 586 #define LDAP_FILTER_PRESENT_30 0xa7 /* context specific + constructed */ 587 588 /* substring filter component types */ 589 #define LDAP_SUBSTRING_INITIAL 0x80 /* context specific */ 590 #define LDAP_SUBSTRING_ANY 0x81 /* context specific */ 591 #define LDAP_SUBSTRING_FINAL 0x82 /* context specific */ 592 593 /* 3.0 compatibility substring filter component types */ 594 #define LDAP_SUBSTRING_INITIAL_30 0xa0 /* context specific */ 595 #define LDAP_SUBSTRING_ANY_30 0xa1 /* context specific */ 596 #define LDAP_SUBSTRING_FINAL_30 0xa2 /* context specific */ 597 598 /* search scopes */ 599 #define LDAP_SCOPE_BASE 0x00 600 #define LDAP_SCOPE_ONELEVEL 0x01 601 #define LDAP_SCOPE_SUBTREE 0x02 602 /* Used when parsing URL, if scope not found. *LDAP_SCOPE_BASE is to use then */ 603 #define LDAP_SCOPE_UNKNOWN 0xFF 604 605 /* ldap_result number of messages that should be returned */ 606 #define LDAP_MSG_ONE 0x00 607 #define LDAP_MSG_ALL 0x01 608 #define LDAP_MSG_RECEIVED 0x02 609 610 611 /* default limit on nesting of referrals */ 612 #define LDAP_DEFAULT_REFHOPLIMIT 5 613 614 615 /* SASL mechanisms */ 616 #define LDAP_SASL_SIMPLE "" 617 #define LDAP_SASL_CRAM_MD5 "CRAM-MD5" 618 #define LDAP_SASL_EXTERNAL "EXTERNAL" 619 /* Next ones are not supported so far by SunDS 2.0 */ 620 #define LDAP_SASL_X511_PROTECTED "X.511-Protected" 621 #define LDAP_SASL_X511_STRONG "X.511-Strong" 622 #define LDAP_SASL_KERBEROS_V4 "KERBEROS_V4" 623 #define LDAP_SASL_GSSAPI "GSSAPI" 624 #define LDAP_SASL_SKEY "SKEY" 625 626 /* 627 * structure for ldap friendly mapping routines 628 */ 629 630 typedef struct friendly { 631 char *f_unfriendly; 632 char *f_friendly; 633 } FriendlyMap; 634 635 636 /* 637 * Structures for URL handling 638 */ 639 typedef struct ldap_url_extension { 640 char *lue_type; 641 char *lue_value; 642 int lue_iscritical; 643 } LDAPURLExt; 644 645 typedef struct ldap_url_desc { 646 char *lud_host; 647 int lud_port; 648 char *lud_dn; 649 char **lud_attrs; 650 int lud_scope; 651 char *lud_filter; 652 LDAPURLExt **lud_extensions; 653 char *lud_string; /* for internal use only */ 654 } LDAPURLDesc; 655 656 #define NULLLDAPURLDESC ((LDAPURLDesc *)NULL) 657 658 #define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */ 659 #define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */ 660 #define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */ 661 #define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */ 662 663 664 /* 665 * possible error codes we can return 666 */ 667 668 #define LDAP_SUCCESS 0x00 669 #define LDAP_OPERATIONS_ERROR 0x01 670 #define LDAP_PROTOCOL_ERROR 0x02 671 #define LDAP_TIMELIMIT_EXCEEDED 0x03 672 #define LDAP_SIZELIMIT_EXCEEDED 0x04 673 #define LDAP_COMPARE_FALSE 0x05 674 #define LDAP_COMPARE_TRUE 0x06 675 #define LDAP_AUTH_METHOD_NOT_SUPPORTED 0x07 676 #define LDAP_STRONG_AUTH_REQUIRED 0x08 677 /* Not used in ldapv3 */ 678 #define LDAP_PARTIAL_RESULTS 0x09 679 680 /* New in ldapv3 */ 681 #define LDAP_REFERRAL 0x0a 682 #define LDAP_ADMINLIMIT_EXCEEDED 0x0b 683 #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c 684 #define LDAP_CONFIDENTIALITY_REQUIRED 0x0d 685 #define LDAP_SASL_BIND_INPROGRESS 0x0e 686 /* End of new */ 687 688 #define LDAP_NO_SUCH_ATTRIBUTE 0x10 689 #define LDAP_UNDEFINED_TYPE 0x11 690 #define LDAP_INAPPROPRIATE_MATCHING 0x12 691 #define LDAP_CONSTRAINT_VIOLATION 0x13 692 #define LDAP_TYPE_OR_VALUE_EXISTS 0x14 693 #define LDAP_INVALID_SYNTAX 0x15 694 695 #define ATTRIBUTE_ERROR(n) ((n & 0xf0) == 0x10) 696 697 #define LDAP_NO_SUCH_OBJECT 0x20 698 #define LDAP_ALIAS_PROBLEM 0x21 699 #define LDAP_INVALID_DN_SYNTAX 0x22 700 /* Following in not used in ldapv3 */ 701 #define LDAP_IS_LEAF 0x23 702 #define LDAP_ALIAS_DEREF_PROBLEM 0x24 703 704 #define NAME_ERROR(n) ((n & 0xf0) == 0x20) 705 706 #define LDAP_INAPPROPRIATE_AUTH 0x30 707 #define LDAP_INVALID_CREDENTIALS 0x31 708 #define LDAP_INSUFFICIENT_ACCESS 0x32 709 #define LDAP_BUSY 0x33 710 #define LDAP_UNAVAILABLE 0x34 711 #define LDAP_UNWILLING_TO_PERFORM 0x35 712 #define LDAP_LOOP_DETECT 0x36 713 714 #define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 */ 715 #define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 */ 716 717 #define LDAP_NAMING_VIOLATION 0x40 718 #define LDAP_OBJECT_CLASS_VIOLATION 0x41 719 #define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 720 #define LDAP_NOT_ALLOWED_ON_RDN 0x43 721 #define LDAP_ALREADY_EXISTS 0x44 722 #define LDAP_NO_OBJECT_CLASS_MODS 0x45 723 #define LDAP_RESULTS_TOO_LARGE 0x46 724 /* Following is new in ldapv3 */ 725 #define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 726 #define LDAP_OTHER 0x50 727 728 /* Reserved for API */ 729 #define LDAP_SERVER_DOWN 0x51 730 #define LDAP_LOCAL_ERROR 0x52 731 #define LDAP_ENCODING_ERROR 0x53 732 #define LDAP_DECODING_ERROR 0x54 733 #define LDAP_TIMEOUT 0x55 734 #define LDAP_AUTH_UNKNOWN 0x56 735 #define LDAP_FILTER_ERROR 0x57 736 #define LDAP_USER_CANCELLED 0x58 737 #define LDAP_PARAM_ERROR 0x59 738 #define LDAP_NO_MEMORY 0x5a 739 740 /* New code with ldapv3 ? */ 741 #define LDAP_CONNECT_ERROR 0x5b 742 #define LDAP_NOT_SUPPORTED 0x5c 743 #define LDAP_CONTROL_NOT_FOUND 0x5d 744 #define LDAP_NO_RESULTS_RETURNED 0x5e 745 #define LDAP_MORE_RESULTS_TO_RETURN 0x5f 746 #define LDAP_CLIENT_LOOP 0x60 747 #define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 748 749 /* debugging stuff */ 750 #ifdef LDAP_DEBUG 751 extern int ldap_debug; 752 #ifdef LDAP_SYSLOG 753 extern int ldap_syslog; 754 extern int ldap_syslog_level; 755 #endif 756 #define LDAP_DEBUG_TRACE 0x001 757 #define LDAP_DEBUG_PACKETS 0x002 758 #define LDAP_DEBUG_ARGS 0x004 759 #define LDAP_DEBUG_CONNS 0x008 760 #define LDAP_DEBUG_BER 0x010 761 #define LDAP_DEBUG_FILTER 0x020 762 #define LDAP_DEBUG_CONFIG 0x040 763 #define LDAP_DEBUG_ACL 0x080 764 #define LDAP_DEBUG_STATS 0x100 765 #define LDAP_DEBUG_STATS2 0x200 766 #define LDAP_DEBUG_SHELL 0x400 767 #define LDAP_DEBUG_PARSE 0x800 768 /* More values for http gateway */ 769 #define LDAP_DEBUG_GWAY 0x1000 770 #define LDAP_DEBUG_GWAYMORE 0x2000 771 772 #define LDAP_DEBUG_ANY 0xffff 773 774 #ifdef LDAP_SYSLOG 775 /* ldaplog is a general logging function that is defined in liblber/i18n.c */ 776 #define Debug(level, fmt, arg1, arg2, arg3) \ 777 { \ 778 if (ldap_debug & level) \ 779 fprintf(stderr, fmt, arg1, arg2, arg3); \ 780 if (ldap_syslog & level) \ 781 ldaplog(level, fmt, arg1, arg2, arg3); \ 782 } 783 #else /* LDAP_SYSLOG */ 784 #ifndef WINSOCK 785 #define Debug(level, fmt, arg1, arg2, arg3) \ 786 if (ldap_debug & level) \ 787 fprintf(stderr, fmt, arg1, arg2, arg3); 788 #else /* !WINSOCK */ 789 extern void Debug(int level, char *fmt, ...); 790 #endif /* !WINSOCK */ 791 #endif /* LDAP_SYSLOG */ 792 #else /* LDAP_DEBUG */ 793 #define Debug(level, fmt, arg1, arg2, arg3) 794 #endif /* LDAP_DEBUG */ 795 796 797 #ifndef NEEDPROTOS 798 extern LDAP *ldap_open(); 799 #ifdef LDAP_SSL 800 extern LDAP *ldap_ssl_open(); 801 #endif /* LDAP_SSL */ 802 extern LDAP *ldap_init(); 803 #ifdef STR_TRANSLATION 804 extern void ldap_set_string_translators(); 805 #ifdef LDAP_CHARSET_8859 806 extern int ldap_t61_to_8859(); 807 extern int ldap_8859_to_t61(); 808 #endif /* LDAP_CHARSET_8859 */ 809 #endif /* STR_TRANSLATION */ 810 extern LDAPMessage *ldap_first_entry(); 811 extern LDAPMessage *ldap_next_entry(); 812 extern char *ldap_get_dn(); 813 extern char *ldap_dn2ufn(); 814 extern char **ldap_explode_dn(); 815 extern char *ldap_first_attribute(); 816 extern char *ldap_next_attribute(); 817 extern char **ldap_get_values(); 818 extern struct berval **ldap_get_values_len(); 819 extern void ldap_value_free(); 820 extern void ldap_value_free_len(); 821 extern int ldap_count_values(); 822 extern int ldap_count_values_len(); 823 extern char *ldap_err2string(); 824 extern void ldap_getfilter_free(); 825 extern LDAPFiltDesc *ldap_init_getfilter(); 826 extern LDAPFiltDesc *ldap_init_getfilter_buf(); 827 extern LDAPFiltInfo *ldap_getfirstfilter(); 828 extern LDAPFiltInfo *ldap_getnextfilter(); 829 extern void ldap_setfilteraffixes(); 830 extern void ldap_build_filter(); 831 extern void ldap_flush_cache(); 832 extern void ldap_set_cache_options(); 833 extern void ldap_uncache_entry(); 834 extern void ldap_uncache_request(); 835 extern char *ldap_friendly_name(); 836 extern void ldap_free_friendlymap(); 837 extern LDAP *cldap_open(); 838 extern void cldap_setretryinfo(); 839 extern void cldap_close(); 840 extern LDAPFiltDesc *ldap_ufn_setfilter(); 841 extern int ldap_ufn_timeout(); 842 extern int ldap_sort_entries(); 843 extern int ldap_sort_values(); 844 extern int ldap_sort_strcasecmp(); 845 void ldap_free_urldesc(); 846 void ldap_free_urlexts(); 847 void ldap_set_rebind_proc(); 848 void ldap_enable_translation(); 849 /* Begin Display Template Prototypes */ 850 typedef int (*writeptype)(); 851 852 int ldap_init_templates(); 853 int ldap_init_templates_buf(); 854 void ldap_free_templates(); 855 struct ldap_disptmpl *ldap_first_disptmpl(); 856 struct ldap_disptmpl *ldap_next_disptmpl(); 857 struct ldap_disptmpl *ldap_name2template(); 858 struct ldap_disptmpl *ldap_oc2template(); 859 char **ldap_tmplattrs(); 860 struct ldap_tmplitem *ldap_first_tmplrow(); 861 struct ldap_tmplitem *ldap_next_tmplrow(); 862 struct ldap_tmplitem *ldap_first_tmplcol(); 863 struct ldap_tmplitem *ldap_next_tmplcol(); 864 int ldap_entry2text_search(); 865 int ldap_entry2text(); 866 int ldap_vals2text(); 867 int ldap_entry2html_search(); 868 int ldap_entry2html(); 869 int ldap_vals2html(); 870 871 int ldap_init_searchprefs(); 872 int ldap_init_searchprefs_buf(); 873 void ldap_free_searchprefs(); 874 struct ldap_searchobj *ldap_first_searchobj(); 875 struct ldap_searchobj *ldap_next_searchobj(); 876 877 #else /* NEEDPROTOS */ 878 #if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK) 879 #include <sys/time.h> 880 #endif 881 882 883 /* 884 * Abandon functions 885 */ 886 int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControl **serverctrls, 887 LDAPControl ** clientctrls); 888 int ldap_abandon(LDAP *ld, int msgid); 889 890 /* 891 * Add functions 892 */ 893 int ldap_add_ext(LDAP *ld, char *dn, LDAPMod **attrs, 894 LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp); 895 int ldap_add_ext_s(LDAP *ld, char *dn, LDAPMod **attrs, 896 LDAPControl ** serverctrls, LDAPControl **clientctrls); 897 int ldap_add(LDAP *ld, char *dn, LDAPMod **attrs); 898 int ldap_add_s(LDAP *ld, char *dn, LDAPMod **attrs); 899 900 /* 901 * Bind functions 902 */ 903 /* DEPRECATED */ 904 int ldap_bind(LDAP *ld, char *who, char *passwd, int authmethod); 905 /* DEPRECATED */ 906 int ldap_bind_s(LDAP *ld, char *who, char *cred, int method); 907 #ifdef LDAP_REFERRALS 908 /* DEPRECATED */ 909 void ldap_set_rebind_proc(LDAP *ld, LDAP_REBIND_FUNCTION *rebindproc, 910 void *extra_arg); 911 #endif /* LDAP_REFERRALS */ 912 913 /* 914 * Simple bind functions 915 */ 916 int ldap_simple_bind(LDAP *ld, char *who, char *passwd); 917 int ldap_simple_bind_s(LDAP *ld, char *who, char *passwd); 918 919 /* 920 * SASL functions 921 */ 922 int ldap_sasl_bind(LDAP *ld, char *dn, char *mechanism, struct berval *cred, 923 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 924 int ldap_sasl_bind_s(LDAP *ld, char *dn, char *mechanism, struct berval *cred, 925 LDAPControl **serverctrls, LDAPControl **clientctrls, 926 struct berval **servercredp); 927 928 /* 929 * Kerberos functions 930 */ 931 /* DEPRECATED */ 932 int ldap_kerberos_bind_s(LDAP *ld, char *who); 933 /* DEPRECATED */ 934 int ldap_kerberos_bind1(LDAP *ld, char *who); 935 /* DEPRECATED */ 936 int ldap_kerberos_bind1_s(LDAP *ld, char *who); 937 /* DEPRECATED */ 938 int ldap_kerberos_bind2(LDAP *ld, char *who); 939 /* DEPRECATED */ 940 int ldap_kerberos_bind2_s(LDAP *ld, char *who); 941 942 #ifndef NO_CACHE 943 /* 944 * Cache functions 945 */ 946 int ldap_enable_cache(LDAP *ld, time_t timeout, ssize_t maxmem); 947 void ldap_disable_cache(LDAP *ld); 948 void ldap_set_cache_options(LDAP *ld, unsigned int opts); 949 void ldap_destroy_cache(LDAP *ld); 950 void ldap_flush_cache(LDAP *ld); 951 void ldap_uncache_entry(LDAP *ld, char *dn); 952 void ldap_uncache_request(LDAP *ld, int msgid); 953 #endif /* !NO_CACHE */ 954 955 /* 956 * Compare functions 957 */ 958 int ldap_compare_ext(LDAP *ld, char *dn, char *attr, struct berval *bvalue, 959 LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp); 960 int ldap_compare_ext_s(LDAP *ld, char *dn, char *attr, struct berval *bvalue, 961 LDAPControl ** serverctrls, LDAPControl **clientctrls); 962 int ldap_compare(LDAP *ld, char *dn, char *attr, char *value); 963 int ldap_compare_s(LDAP *ld, char *dn, char *attr, char *value); 964 965 /* 966 * Delete functions 967 */ 968 int ldap_delete_ext(LDAP *ld, char *dn, LDAPControl **serverctrls, 969 LDAPControl **clientctrls, int *msgidp); 970 int ldap_delete_ext_s(LDAP *ld, char *dn, LDAPControl **serverctrls, 971 LDAPControl **clientctrls); 972 int ldap_delete(LDAP *ld, char *dn); 973 int ldap_delete_s(LDAP *ld, char *dn); 974 975 /* 976 * Error functions 977 */ 978 char *ldap_err2string(int err); 979 980 /* DEPRECATED */ 981 int ldap_result2error(LDAP *ld, LDAPMessage *r, int freeit); 982 /* DEPRECATED */ 983 void ldap_perror(LDAP *ld, char *s); 984 985 /* 986 * Modify functions 987 */ 988 int ldap_modify_ext(LDAP *ld, char *dn, LDAPMod **mods, 989 LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp); 990 int ldap_modify_ext_s(LDAP *ld, char *dn, LDAPMod **mods, 991 LDAPControl **serverctrls, LDAPControl **clientctrls); 992 int ldap_modify(LDAP *ld, char *dn, LDAPMod **mods); 993 int ldap_modify_s(LDAP *ld, char *dn, LDAPMod **mods); 994 995 /* 996 * Modrdn functions 997 */ 998 999 /* DEPRECATED : use ldap_rename instead */ 1000 int ldap_modrdn0(LDAP *ld, char *dn, char *newrdn); 1001 /* DEPRECATED : use ldap_rename_s instead */ 1002 int ldap_modrdn0_s(LDAP *ld, char *dn, char *newrdn); 1003 /* DEPRECATED : use ldap_rename instead */ 1004 int ldap_modrdn(LDAP *ld, char *dn, char *newrdn, 1005 int deleteoldrdn); 1006 /* DEPRECATED : use ldap_rename_s instead */ 1007 int ldap_modrdn_s(LDAP *ld, char *dn, char *newrdn, 1008 int deleteoldrdn); 1009 1010 /* 1011 * Rename functions 1012 */ 1013 int ldap_rename(LDAP *ld, char *dn, char *newrdn, char *newparent, 1014 int deleteoldrdn, LDAPControl ** serverctrls, 1015 LDAPControl **clientctrls, int *msgidp); 1016 int ldap_rename_s(LDAP *ld, char *dn, char *newrdn, char *newparent, 1017 int deleteoldrdn, LDAPControl ** serverctrls, 1018 LDAPControl **clientctrls); 1019 1020 /* 1021 * Init/Open functions 1022 */ 1023 LDAP *ldap_init(char *defhost, int defport); 1024 1025 /* DEPRECATED : use ldap_init instead */ 1026 LDAP *ldap_open(char *host, int port); 1027 1028 #ifdef LDAP_SSL 1029 LDAP *ldap_ssl_init(char *defhost, int defport, char *keyname); 1030 1031 /* DEPRECATED : use ldap_ssl_init instead */ 1032 LDAP *ldap_ssl_open(char *host, int port, char *keyname); 1033 #endif 1034 1035 /* 1036 * Entry functions 1037 */ 1038 LDAPMessage *ldap_first_entry(LDAP *ld, LDAPMessage *res); 1039 LDAPMessage *ldap_next_entry(LDAP *ld, LDAPMessage *entry); 1040 int ldap_count_entries(LDAP *ld, LDAPMessage *res); 1041 1042 /* 1043 * Message functions 1044 */ 1045 LDAPMessage *ldap_first_message(LDAP *ld, LDAPMessage *res); 1046 LDAPMessage *ldap_next_message(LDAP *ld, LDAPMessage *msg); 1047 int ldap_count_messages(LDAP *ld, LDAPMessage *res); 1048 1049 /* 1050 * Reference functions 1051 */ 1052 LDAPMessage *ldap_first_reference(LDAP *ld, LDAPMessage *res); 1053 LDAPMessage *ldap_next_reference(LDAP *ld, LDAPMessage *msg); 1054 int ldap_count_references(LDAP *ld, LDAPMessage *res); 1055 char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res); 1056 1057 /* 1058 * Entry functions 1059 */ 1060 LDAPMessage *ldap_delete_result_entry(LDAPMessage **list, 1061 LDAPMessage *e); 1062 void ldap_add_result_entry(LDAPMessage **list, LDAPMessage *e); 1063 1064 /* 1065 * DN functions 1066 */ 1067 char *ldap_get_dn(LDAP *ld, LDAPMessage *entry); 1068 char **ldap_explode_dn(char *dn, int notypes); 1069 char ** ldap_explode_rdn(char *rdn, int notypes); 1070 char *ldap_dn2ufn(char *dn); 1071 1072 char **ldap_explode_dns(char *dn); 1073 int ldap_is_dns_dn(char *dn); 1074 char *ldap_dns_to_dn(char *dns_name, int *nameparts); 1075 1076 /* 1077 * Attribute parsing functions 1078 */ 1079 char *ldap_first_attribute(LDAP *ld, LDAPMessage *entry, 1080 BerElement **ber); 1081 char *ldap_next_attribute(LDAP *ld, LDAPMessage *entry, 1082 BerElement *ber); 1083 void ldap_memfree(char *mem); 1084 1085 /* 1086 * Attribute Value functions 1087 */ 1088 char **ldap_get_values(LDAP *ld, LDAPMessage *entry, char *target); 1089 struct berval **ldap_get_values_len(LDAP *ld, LDAPMessage *entry, 1090 char *target); 1091 int ldap_count_values(char **vals); 1092 int ldap_count_values_len(struct berval **vals); 1093 void ldap_value_free(char **vals); 1094 void ldap_value_free_len(struct berval **vals); 1095 1096 /* 1097 * Result functions 1098 */ 1099 int ldap_result(LDAP *ld, int msgid, int all, 1100 struct timeval *timeout, LDAPMessage **result); 1101 int ldap_msgdelete(LDAP *ld, int msgid); 1102 int ldap_msgfree(LDAPMessage *lm); 1103 int ldap_msgtype(LDAPMessage *res); 1104 int ldap_msgid(LDAPMessage *res); 1105 int ldap_parse_result(LDAP *ld, LDAPMessage *res, int *errcodep, 1106 char **matcheddnp, char **errmsgp, char ***referralsp, 1107 LDAPControl ***serverctrlsp, int freeit); 1108 int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res, 1109 struct berval **servercredp, int freeit); 1110 int ldap_parse_extended_result(LDAP *ld, LDAPMessage *res, 1111 char **resultoidp, struct berval **resultdata, int freeit); 1112 int cldap_getmsg(LDAP *ld, struct timeval *timeout, BerElement *ber); 1113 1114 1115 /* 1116 * Search functions 1117 */ 1118 int ldap_search_ext(LDAP *ld, char *base, int scope, char *filter, 1119 char **attrs, int attrsonly, LDAPControl **serverctrls, 1120 LDAPControl **clientctrls, struct timeval *timeoutp, 1121 int sizelimit, int *msgidp); 1122 int ldap_search_ext_s(LDAP *ld, char *base, int scope, char *filter, 1123 char **attrs, int attrsonly, LDAPControl **serverctrls, 1124 LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit, 1125 LDAPMessage **res); 1126 1127 int ldap_search(LDAP *ld, char *base, int scope, char *filter, 1128 char **attrs, int attrsonly); 1129 int ldap_search_s(LDAP *ld, char *base, int scope, char *filter, 1130 char **attrs, int attrsonly, LDAPMessage **res); 1131 int ldap_search_st(LDAP *ld, char *base, int scope, char *filter, 1132 char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res); 1133 1134 /* 1135 * UFN functions 1136 */ 1137 int ldap_ufn_search_c(LDAP *ld, char *ufn, char **attrs, 1138 int attrsonly, LDAPMessage **res, int (*cancelproc)(void *cl), 1139 void *cancelparm); 1140 int ldap_ufn_search_ct(LDAP *ld, char *ufn, char **attrs, 1141 int attrsonly, LDAPMessage **res, int (*cancelproc)(void *cl), 1142 void *cancelparm, char *tag1, char *tag2, char *tag3); 1143 int ldap_ufn_search_s(LDAP *ld, char *ufn, char **attrs, 1144 int attrsonly, LDAPMessage **res); 1145 LDAPFiltDesc *ldap_ufn_setfilter(LDAP *ld, char *fname); 1146 void ldap_ufn_setprefix(LDAP *ld, char *prefix); 1147 int ldap_ufn_timeout(void *tvparam); 1148 1149 1150 /* 1151 * Unbind functions 1152 */ 1153 int ldap_unbind(LDAP *ld); 1154 int ldap_unbind_s(LDAP *ld); 1155 1156 1157 /* 1158 * Filter functions 1159 */ 1160 LDAPFiltDesc *ldap_init_getfilter(char *fname); 1161 LDAPFiltDesc *ldap_init_getfilter_buf(char *buf, ssize_t buflen); 1162 LDAPFiltInfo *ldap_getfirstfilter(LDAPFiltDesc *lfdp, char *tagpat, 1163 char *value); 1164 LDAPFiltInfo *ldap_getnextfilter(LDAPFiltDesc *lfdp); 1165 void ldap_setfilteraffixes(LDAPFiltDesc *lfdp, char *prefix, char *suffix); 1166 void ldap_build_filter(char *buf, size_t buflen, 1167 char *pattern, char *prefix, char *suffix, char *attr, 1168 char *value, char **valwords); 1169 1170 /* 1171 * Functions to free LDAPFiltDesc and LDAPmod 1172 */ 1173 void ldap_getfilter_free(LDAPFiltDesc *lfdp); 1174 void ldap_mods_free(LDAPMod **mods, int freemods); 1175 1176 /* 1177 * Friendly name functions 1178 */ 1179 char *ldap_friendly_name(char *filename, char *uname, 1180 FriendlyMap **map); 1181 void ldap_free_friendlymap(FriendlyMap **map); 1182 1183 1184 /* 1185 * Connectionless LDAP functions 1186 */ 1187 LDAP *cldap_open(char *host, int port); 1188 void cldap_close(LDAP *ld); 1189 int cldap_search_s(LDAP *ld, char *base, int scope, char *filter, 1190 char **attrs, int attrsonly, LDAPMessage **res, char *logdn); 1191 void cldap_setretryinfo(LDAP *ld, int tries, time_t timeout); 1192 1193 1194 /* 1195 * Sort functions 1196 */ 1197 int ldap_sort_entries(LDAP *ld, LDAPMessage **chain, char *attr, 1198 int (*cmp)()); 1199 int ldap_sort_values(LDAP *ld, char **vals, int (*cmp)()); 1200 int ldap_sort_strcasecmp(char **a, char **b); 1201 1202 1203 /* 1204 * URL functions 1205 */ 1206 int ldap_is_ldap_url(char *url); 1207 int ldap_url_parse(char *url, LDAPURLDesc **ludpp); 1208 void ldap_free_urlexts(LDAPURLExt **lues); 1209 void ldap_free_urldesc(LDAPURLDesc *ludp); 1210 int ldap_url_search(LDAP *ld, char *url, int attrsonly); 1211 int ldap_url_search_s(LDAP *ld, char *url, int attrsonly, 1212 LDAPMessage **res); 1213 int ldap_url_search_st(LDAP *ld, char *url, int attrsonly, 1214 struct timeval *timeout, LDAPMessage **res); 1215 char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs, 1216 char *scope, char *filter); 1217 char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts); 1218 1219 1220 /* 1221 * in Character Set functions 1222 */ 1223 #ifdef STR_TRANSLATION 1224 void ldap_set_string_translators(LDAP *ld, 1225 BERTranslateProc encode_proc, BERTranslateProc decode_proc); 1226 int ldap_translate_from_t61(LDAP *ld, char **bufp, 1227 unsigned int *lenp, int free_input); 1228 int ldap_translate_to_t61(LDAP *ld, char **bufp, 1229 unsigned int *lenp, int free_input); 1230 void ldap_enable_translation(LDAP *ld, LDAPMessage *entry, 1231 int enable); 1232 1233 #ifdef LDAP_CHARSET_8859 1234 int ldap_t61_to_8859(char **bufp, unsigned int *buflenp, 1235 int free_input); 1236 int ldap_8859_to_t61(char **bufp, unsigned int *buflenp, 1237 int free_input); 1238 #endif /* LDAP_CHARSET_8859 */ 1239 #endif /* STR_TRANSLATION */ 1240 1241 /* 1242 * Diplay Template functions 1243 */ 1244 typedef int (*writeptype)(void *writeparm, char *p, int len); 1245 1246 int ldap_init_templates(char *file, 1247 struct ldap_disptmpl **tmpllistp); 1248 1249 int ldap_init_templates_buf(char *buf, ssize_t buflen, 1250 struct ldap_disptmpl **tmpllistp); 1251 1252 void ldap_free_templates(struct ldap_disptmpl *tmpllist); 1253 1254 struct ldap_disptmpl *ldap_first_disptmpl( 1255 struct ldap_disptmpl *tmpllist); 1256 1257 struct ldap_disptmpl *ldap_next_disptmpl( 1258 struct ldap_disptmpl *tmpllist, struct ldap_disptmpl *tmpl); 1259 1260 struct ldap_disptmpl *ldap_name2template(char *name, 1261 struct ldap_disptmpl *tmpllist); 1262 1263 struct ldap_disptmpl *ldap_oc2template(char **oclist, 1264 struct ldap_disptmpl *tmpllist); 1265 1266 char **ldap_tmplattrs(struct ldap_disptmpl *tmpl, 1267 char **includeattrs, int exclude, unsigned int syntaxmask); 1268 1269 struct ldap_tmplitem *ldap_first_tmplrow(struct ldap_disptmpl *tmpl); 1270 1271 struct ldap_tmplitem *ldap_next_tmplrow(struct ldap_disptmpl *tmpl, 1272 struct ldap_tmplitem *row); 1273 1274 struct ldap_tmplitem *ldap_first_tmplcol(struct ldap_disptmpl *tmpl, 1275 struct ldap_tmplitem *row); 1276 1277 struct ldap_tmplitem *ldap_next_tmplcol(struct ldap_disptmpl *tmpl, 1278 struct ldap_tmplitem *row, struct ldap_tmplitem *col); 1279 1280 int ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry, 1281 struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, 1282 writeptype writeproc, void *writeparm, char *eol, 1283 int rdncount, unsigned int opts); 1284 1285 int ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label, 1286 int labelwidth, unsigned int syntaxid, writeptype writeproc, 1287 void *writeparm, char *eol, int rdncount); 1288 1289 int ldap_entry2text_search(LDAP *ld, char *dn, char *base, 1290 LDAPMessage *entry, struct ldap_disptmpl *tmpllist, 1291 char **defattrs, char ***defvals, writeptype writeproc, 1292 void *writeparm, char *eol, int rdncount, unsigned int opts); 1293 1294 int ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry, 1295 struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, 1296 writeptype writeproc, void *writeparm, char *eol, 1297 int rdncount, unsigned int opts, char *urlprefix, char *base); 1298 1299 int ldap_vals2html(LDAP *ld, char *buf, char **vals, char *label, 1300 int labelwidth, unsigned int syntaxid, writeptype writeproc, 1301 void *writeparm, char *eol, int rdncount, char *urlprefix); 1302 1303 int ldap_entry2html_search(LDAP *ld, char *dn, char *base, 1304 LDAPMessage *entry, struct ldap_disptmpl *tmpllist, 1305 char **defattrs, char ***defvals, writeptype writeproc, 1306 void *writeparm, char *eol, int rdncount, unsigned int opts, 1307 char *urlprefix); 1308 1309 1310 /* 1311 * Search Preferences functions 1312 */ 1313 int ldap_init_searchprefs(char *file, 1314 struct ldap_searchobj **solistp); 1315 1316 int ldap_init_searchprefs_buf(char *buf, ssize_t buflen, 1317 struct ldap_searchobj **solistp); 1318 1319 void ldap_free_searchprefs(struct ldap_searchobj *solist); 1320 1321 struct ldap_searchobj *ldap_first_searchobj( 1322 struct ldap_searchobj *solist); 1323 1324 struct ldap_searchobj *ldap_next_searchobj( 1325 struct ldap_searchobj *sollist, struct ldap_searchobj *so); 1326 1327 1328 /* 1329 * Option functions 1330 */ 1331 int ldap_get_option(LDAP *ld, int option, void *outvalue); 1332 int ldap_set_option(LDAP *ld, int option, void *invalue); 1333 1334 1335 /* 1336 * Control functions 1337 */ 1338 void ldap_control_free(LDAPControl *ctrl); 1339 void ldap_controls_free(LDAPControl **ctrls); 1340 1341 1342 /* 1343 * Simple Page Control functions 1344 */ 1345 int ldap_create_page_control(LDAP *ld, unsigned int pagesize, 1346 struct berval *cookie, char isCritical, LDAPControl **output); 1347 int ldap_parse_page_control(LDAP *ld, LDAPControl **controls, 1348 unsigned int *totalcount, struct berval **cookie); 1349 1350 /* 1351 * Server Side Sort control functions 1352 */ 1353 int ldap_create_sort_control(LDAP *ld, LDAPsortkey **sortKeyList, 1354 const char ctl_iscritical, LDAPControl **ctrlp); 1355 int ldap_parse_sort_control(LDAP *ld, LDAPControl **ctrlp, 1356 unsigned long *result, char **attribute); 1357 int ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, char *string_rep); 1358 void ldap_free_sort_keylist(LDAPsortkey **sortKeyList); 1359 1360 /* 1361 * Virtual List View control functions 1362 */ 1363 int ldap_create_virtuallist_control(LDAP *ld, LDAPVirtualList *ldvlistp, 1364 LDAPControl **ctrlp); 1365 int ldap_parse_virtuallist_control(LDAP *ld, LDAPControl **ctrls, 1366 unsigned long *target_posp, unsigned long *list_sizep, 1367 int *errcodep); 1368 1369 #endif /* NEEDPROTOS */ 1370 1371 #ifdef __cplusplus 1372 } 1373 #endif 1374 1375 #endif /* _LDAP_H */ 1376