Tang Cheng | 37650ea | 2014-10-20 16:14:41 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * $Header: ldap/public/ldap.h /main/28 2008/09/26 16:32:41 vmedam Exp $ |
| 3 | */ |
| 4 | |
| 5 | /* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.*/ |
| 6 | /* |
| 7 | NAME |
| 8 | ldap.h - Used by clients. |
| 9 | DESCRIPTION |
| 10 | <short description of component this file declares/defines> |
| 11 | PUBLIC FUNCTION(S) |
| 12 | <list of external functions declared/defined - with one-line descriptions> |
| 13 | PRIVATE FUNCTION(S) |
| 14 | <list of static functions defined in .c file - with one-line descriptions> |
| 15 | RETURNS |
| 16 | <function return values, for .c file with single function> |
| 17 | NOTES |
| 18 | <other useful comments, qualifications, etc.> |
| 19 | MODIFIED (MM/DD/YY) |
| 20 | vmedam 09/25/08 - |
| 21 | ******** 09/17/08 - bug#7312369 |
| 22 | ******** 03/20/08 - bug#5743318 |
| 23 | ******** 03/17/08 - Bug 6838567 |
| 24 | ******** 09/16/05 - fix bug#3935094 |
| 25 | ******** 05/09/05 - Bug 4288744 |
| 26 | ******** 06/11/04 - Bug 3512354 |
| 27 | ******** 02/12/04 - Removing data type mismatch with internal definitions |
| 28 | ****** 10/22/03 - fix bug 1869186 |
| 29 | ****** 10/01/03 - Add ora_ldap_init_clientctx |
| 30 | ****** 08/11/03 - Add new option for sasl credentials |
| 31 | ******** 02/22/03 - bugfix #2802996 |
| 32 | ****** 02/02/03 - Add SASL interfaces |
| 33 | ******** 10/15/02 - client side referral cache changes |
| 34 | ******** 10/12/02 - change in discovery api's |
| 35 | ******** 04/30/01 - fix compilation errors |
| 36 | ******* 04/13/01 - add normalize DN protos |
| 37 | ****** 04/07/01 - v3 Modifications |
| 38 | ***** 06/02/00 - fix bug 1294614 |
| 39 | ***** 03/31/00 - fix porting except. # 1234272 |
| 40 | ****** 05/19/98 - Initial Creation |
| 41 | */ |
| 42 | /* |
| 43 | * Copyright (c) 1990, 2008, Oracle and/or its affiliates. All rights reserved. |
| 44 | * All rights reserved. |
| 45 | * |
| 46 | * Redistribution and use in source and binary forms are permitted |
| 47 | * provided that this notice is preserved and that due credit is given |
| 48 | * to the University of Michigan at Ann Arbor. The name of the University |
| 49 | * may not be used to endorse or promote products derived from this |
| 50 | * software without specific prior written permission. This software |
| 51 | * is provided ``as is'' without express or implied warranty. |
| 52 | */ |
| 53 | |
| 54 | #ifndef GSLC_ORACLE |
| 55 | #define GSLC_ORACLE |
| 56 | |
| 57 | #ifdef __cplusplus |
| 58 | extern "C" { |
| 59 | #endif |
| 60 | |
| 61 | |
| 62 | #ifdef WINSOCK |
| 63 | #include "msdos.h" |
| 64 | #include <winsock.h> |
| 65 | #endif |
| 66 | |
| 67 | /* BER classes and mask */ |
| 68 | #define LBER_CLASS_UNIVERSAL 0x00 |
| 69 | #define LBER_CLASS_APPLICATION 0x40 |
| 70 | #define LBER_CLASS_CONTEXT 0x80 |
| 71 | #define LBER_CLASS_PRIVATE 0xc0 |
| 72 | #define LBER_CLASS_MASK 0xc0 |
| 73 | |
| 74 | /* BER encoding type and mask */ |
| 75 | #define LBER_PRIMITIVE 0x00 |
| 76 | #define LBER_CONSTRUCTED 0x20 |
| 77 | #define LBER_ENCODING_MASK 0x20 |
| 78 | |
| 79 | #define LBER_BIG_TAG_MASK 0x1f |
| 80 | #define LBER_MORE_TAG_MASK 0x80 |
| 81 | |
| 82 | /* |
| 83 | * Note that LBER_ERROR and LBER_DEFAULT are values that can never appear |
| 84 | * as valid BER tags, and so it is safe to use them to report errors. In |
| 85 | * fact, any tag for which the following is true is invalid: |
| 86 | * (( tag & 0x00000080 ) != 0 ) && (( tag & 0xFFFFFF00 ) != 0 ) |
| 87 | */ |
| 88 | #define LBER_ERROR -1 |
| 89 | #define LBER_DEFAULT -1 |
| 90 | |
| 91 | /* general BER types we know about */ |
| 92 | #define LBER_BOOLEAN 0x01L |
| 93 | #define LBER_INTEGER 0x02L |
| 94 | #define LBER_BITSTRING 0x03L |
| 95 | #define LBER_OCTETSTRING 0x04L |
| 96 | #define LBER_NULL 0x05L |
| 97 | #define LBER_ENUMERATED 0x0aL |
| 98 | #define LBER_SEQUENCE 0x30L /* constructed */ |
| 99 | #define LBER_SET 0x31L /* constructed */ |
| 100 | |
| 101 | #define OLD_LBER_SEQUENCE 0x10L /* w/o constructed bit - broken */ |
| 102 | #define OLD_LBER_SET 0x11L /* w/o constructed bit - broken */ |
| 103 | |
| 104 | typedef int (*BERTranslateProc)( char **bufp, unsigned int *buflenp, |
| 105 | int free_input ); |
| 106 | |
| 107 | typedef struct seqorset { |
| 108 | unsigned int sos_clen; |
| 109 | unsigned int sos_tag; |
| 110 | char *sos_first; |
| 111 | char *sos_ptr; |
| 112 | struct seqorset *sos_next; |
| 113 | } Seqorset; |
| 114 | #define NULLSEQORSET ((Seqorset *) 0) |
| 115 | |
| 116 | #define SOS_STACK_SIZE 8 /* depth of the pre-allocated sos structure stack */ |
| 117 | |
| 118 | typedef struct berelement { |
| 119 | char *ber_buf; |
| 120 | char *ber_ptr; |
| 121 | char *ber_end; |
| 122 | struct seqorset *ber_sos; |
| 123 | unsigned int ber_tag; |
| 124 | unsigned int ber_len; |
| 125 | int ber_usertag; |
| 126 | char ber_options; |
| 127 | #define LBER_USE_DER 0x01 |
| 128 | #define LBER_USE_INDEFINITE_LEN 0x02 |
| 129 | #define LBER_TRANSLATE_STRINGS 0x04 |
| 130 | char *ber_rwptr; |
| 131 | BERTranslateProc ber_encode_translate_proc; |
| 132 | BERTranslateProc ber_decode_translate_proc; |
| 133 | int ber_flags; |
| 134 | int ber_sos_stack_posn; |
| 135 | Seqorset ber_sos_stack[SOS_STACK_SIZE]; |
| 136 | } BerElement; |
| 137 | #define NULLBER ((BerElement *) 0) |
| 138 | |
| 139 | /* sgsluns - private network endpoint type |
| 140 | */ |
| 141 | struct sgsluns |
| 142 | { |
| 143 | int sock_sgsluns; /* socket identifier */ |
| 144 | long state_sgsluns; /* sgsluns state flag (SGSLUNS_STATE_xxx) */ |
| 145 | char saddr_sgsluns[32]; /* inet address of other end of this connection |
| 146 | * in the form A.B.C.D where A,B,C, and D are |
| 147 | * base 256 notation integers. eg. "192.0.0.1" |
| 148 | */ |
| 149 | }; |
| 150 | typedef struct sgsluns sgsluns; |
| 151 | |
| 152 | typedef struct sockbuf { |
| 153 | #ifndef MACOS |
| 154 | int sb_sd; |
| 155 | #else /* MACOS */ |
| 156 | void *sb_sd; |
| 157 | #endif /* MACOS */ |
| 158 | BerElement sb_ber; |
| 159 | |
| 160 | int sb_naddr; /* > 0 implies using CLDAP (UDP) */ |
| 161 | void *sb_useaddr; /* pointer to sockaddr to use next */ |
| 162 | void *sb_fromaddr; /* pointer to message source sockaddr */ |
| 163 | void **sb_addrs; /* actually an array of pointers to |
| 164 | sockaddrs */ |
| 165 | |
| 166 | int sb_options; /* to support copying ber elements */ |
| 167 | #define LBER_TO_FILE 0x01 /* to a file referenced by sb_fd */ |
| 168 | #define LBER_TO_FILE_ONLY 0x02 /* only write to file, not network */ |
| 169 | #define LBER_MAX_INCOMING_SIZE 0x04 /* impose limit on incoming stuff */ |
| 170 | #define LBER_NO_READ_AHEAD 0x08 /* read only as much as requested */ |
| 171 | int sb_fd; |
| 172 | int sb_max_incoming; |
| 173 | void *sb_nzenv; /* nzos environment pointer */ |
| 174 | void *sb_sslContext; |
| 175 | int sb_sslauth; /* type of ssl authentication */ |
| 176 | int sb_sslflag; |
| 177 | int ssl_sd; |
| 178 | sgsluns *sb_endp; /* socket end point */ |
| 179 | } Sockbuf; |
| 180 | #define READBUFSIZ 8192 |
| 181 | |
| 182 | /* structure for returning a sequence of octet strings + length */ |
| 183 | struct berval { |
| 184 | unsigned int bv_len; |
| 185 | char *bv_val; |
| 186 | }; |
| 187 | |
| 188 | #define LDAP_PORT 389 |
| 189 | #define LDAP_SSL_PORT 636 |
| 190 | |
| 191 | #ifndef DEF_SSL_PORT |
| 192 | extern int sslmodeenabled ; |
| 193 | #endif |
| 194 | |
| 195 | #define LDAP_VERSION1 1 |
| 196 | #define LDAP_VERSION2 2 |
| 197 | #define LDAP_VERSION3 3 |
| 198 | |
| 199 | #define LDAP_VERSION LDAP_VERSION2 /*default should stay as LDAPv2*/ |
| 200 | |
| 201 | #define LDAP_VERSION_MAX LDAP_VERSION3 |
| 202 | |
| 203 | #define COMPAT20 |
| 204 | #define COMPAT30 |
| 205 | #if defined(COMPAT20) || defined(COMPAT30) |
| 206 | #define COMPAT |
| 207 | #endif |
| 208 | |
| 209 | #define LDAP_MAX_ATTR_LEN 256 |
| 210 | |
| 211 | /* various options that can be set/unset */ |
| 212 | #define LDAP_OPT_DESC 1 |
| 213 | #define LDAP_OPT_DEREF 2 |
| 214 | #define LDAP_OPT_SIZELIMIT 3 |
| 215 | #define LDAP_OPT_TIMELIMIT 4 |
| 216 | #define LDAP_OPT_THREAD_FN_PTRS 5 |
| 217 | #define LDAP_OPT_REBIND_FN 6 |
| 218 | #define LDAP_OPT_REBIND_ARG 7 |
| 219 | #define LDAP_OPT_REFERRALS 8 |
| 220 | #define LDAP_OPT_RESTART 9 |
| 221 | #define LDAP_OPT_SSL 10 |
| 222 | #define LDAP_OPT_IO_FN_PTRS 11 |
| 223 | #define LDAP_OPT_CACHE_FN_PTRS 13 |
| 224 | #define LDAP_OPT_CACHE_STRATEGY 14 |
| 225 | #define LDAP_OPT_CACHE_ENABLE 15 |
| 226 | #define LDAP_OPT_REFERRAL_HOP_LIMIT 16 |
| 227 | #define LDAP_OPT_PROTOCOL_VERSION 17 |
| 228 | #define LDAP_OPT_SERVER_CONTROLS 18 |
| 229 | #define LDAP_OPT_CLIENT_CONTROLS 19 |
| 230 | #define LDAP_OPT_PREFERRED_LANGUAGE 20 |
| 231 | #define LDAP_OPT_ERROR_NUMBER 49 |
| 232 | #define LDAP_OPT_ERROR_STRING 50 |
| 233 | |
| 234 | /* client side referral cache enable option */ |
| 235 | #define ORA_LDAP_OPT_RFRL_CACHE 200 |
| 236 | |
| 237 | /* ldap connect timeout */ |
| 238 | #define ORA_LDAP_OPT_CONNECT_TIMEOUT 210 |
| 239 | |
| 240 | /* directory server types */ |
| 241 | #define LDAP_DIRTYPE_OID 1 /* Oracle Internet Directory */ |
| 242 | #define LDAP_DIRTYPE_AD 2 /* Microsoft Active Directory */ |
| 243 | #define LDAP_DIRTYPE_NETSCAPE 4 /* Netscape Directory Server */ |
| 244 | #define LDAP_DIRTYPE_NDS 8 /* Novell Directory Service */ |
| 245 | #define LDAP_DIRTYPE_UNKNOWN 4096 /* Unknown */ |
| 246 | |
| 247 | /* for on/off options */ |
| 248 | #define LDAP_OPT_ON ((void *)1) |
| 249 | #define LDAP_OPT_OFF ((void *)0) |
| 250 | |
| 251 | |
| 252 | /* SSL Authentication modes */ |
| 253 | #define GSLC_SSL_NO_AUTH 1 |
| 254 | #define GSLC_SSL_ONEWAY_AUTH 32 |
| 255 | #define GSLC_SSL_TWOWAY_AUTH 64 |
| 256 | |
| 257 | |
| 258 | /* Abandon support */ |
| 259 | #define ABANDONorTL(op) ((op)->o_abandon == 1) |
| 260 | |
| 261 | /* debugging stuff */ |
| 262 | #ifdef LDAP_DEBUG |
| 263 | extern int ldap_debug; |
| 264 | extern unsigned int debug_flag; |
| 265 | #define LDAP_DEBUG_TRACE 0x001 |
| 266 | #define LDAP_DEBUG_PACKETS 0x002 |
| 267 | #define LDAP_DEBUG_ARGS 0x004 |
| 268 | #define LDAP_DEBUG_CONNS 0x008 |
| 269 | #define LDAP_DEBUG_BER 0x010 |
| 270 | #define LDAP_DEBUG_FILTER 0x020 |
| 271 | #define LDAP_DEBUG_CONFIG 0x040 |
| 272 | #define LDAP_DEBUG_ACL 0x080 |
| 273 | #define LDAP_DEBUG_STATS 0x100 |
| 274 | #define LDAP_DEBUG_STATS2 0x200 |
| 275 | #define LDAP_DEBUG_SHELL 0x400 |
| 276 | #define LDAP_DEBUG_PARSE 0x800 |
| 277 | #define LDAP_DEBUG_PROCESS 0x2000 |
| 278 | #define LDAP_DEBUG_MUST 0x4000 |
| 279 | #ifndef LDAP_DEBUG_ANY |
| 280 | # define LDAP_DEBUG_ANY 0xffff |
| 281 | #endif /* LDAP_DEBUG_ANY */ |
| 282 | |
| 283 | #ifdef LDAP_SYSLOG |
| 284 | #define Debug( level, fmt, arg1, arg2, arg3 ) \ |
| 285 | { \ |
| 286 | if ( ldap_debug & level ) \ |
| 287 | fprintf( stderr, fmt, arg1, arg2, arg3 ); \ |
| 288 | } |
| 289 | #else /* LDAP_SYSLOG */ |
| 290 | #ifndef WINSOCK |
| 291 | #define Debug( level, fmt, arg1, arg2, arg3 ) \ |
| 292 | if ( ldap_debug & level ) \ |
| 293 | fprintf( stderr, fmt, arg1, arg2, arg3 ); |
| 294 | #else /* !WINSOCK */ |
| 295 | extern void Debug( int level, char* fmt, ... ); |
| 296 | #endif /* !WINSOCK */ |
| 297 | #endif /* LDAP_SYSLOG */ |
| 298 | #else /* LDAP_DEBUG */ |
| 299 | #define Debug( level, fmt, arg1, arg2, arg3 ) |
| 300 | #endif /* LDAP_DEBUG */ |
| 301 | |
| 302 | /* |
| 303 | * specific LDAP instantiations of BER types we know about |
| 304 | */ |
| 305 | |
| 306 | /* general stuff */ |
| 307 | #define LDAP_TAG_MESSAGE 0x30L /* tag is 0x10 + constructed bit */ |
| 308 | #define OLD_LDAP_TAG_MESSAGE 0x10L /* forgot the constructed bit */ |
| 309 | #define LDAP_TAG_MSGID 0x02L /* INTEGER */ |
| 310 | #define LDAP_TAG_LDAPDN 0x04L /* OCTET STRING */ |
| 311 | #define LDAP_TAG_CONTROLS 0xa0L /* context specific + constructed + 0 */ |
| 312 | #define LDAP_TAG_REFERRAL 0xa3L /* context specific + constructed + 3 */ |
| 313 | #define LDAP_TAG_NEWSUPERIOR 0x80L /* context specific + primitive */ |
| 314 | #define LDAP_TAG_MRA_OID 0x81L /* context specific + primitive */ |
| 315 | #define LDAP_TAG_MRA_TYPE 0x82L /* context specific + primitive */ |
| 316 | #define LDAP_TAG_MRA_VALUE 0x83L /* context specific + primitive */ |
| 317 | #define LDAP_TAG_MRA_DNATTRS 0x84L /* context specific + primitive */ |
| 318 | #define LDAP_TAG_EXOP_REQ_OID 0x80L /* context specific + primitive */ |
| 319 | #define LDAP_TAG_EXOP_REQ_VALUE 0x81L /* context specific + primitive */ |
| 320 | #define LDAP_TAG_EXOP_RES_OID 0x8aL /* context specific + primitive */ |
| 321 | #define LDAP_TAG_EXOP_RES_VALUE 0x8bL /* context specific + primitive */ |
| 322 | #define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive */ |
| 323 | #define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive */ |
| 324 | #define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive */ |
| 325 | #define LDAP_TAG_SASL_RES_CREDS 0x87L /* context specific + primitive */ |
| 326 | #define LDAP_TAG_VLV_BY_INDEX 0xa0L /* context specific + constructed + 0 */ |
| 327 | #define LDAP_TAG_VLV_BY_VALUE 0x81L /* context specific + primitive + 1 */ |
| 328 | |
| 329 | /* possible operations a client can invoke */ |
| 330 | #define LDAP_REQ_BIND 0x60L /* application + constructed */ |
| 331 | #define LDAP_REQ_UNBIND 0x42L /* application + primitive */ |
| 332 | #define LDAP_REQ_SEARCH 0x63L /* application + constructed */ |
| 333 | #define LDAP_REQ_MODIFY 0x66L /* application + constructed */ |
| 334 | #define LDAP_REQ_ADD 0x68L /* application + constructed */ |
| 335 | #define LDAP_REQ_DELETE 0x4aL /* application + primitive */ |
| 336 | #define LDAP_REQ_MODRDN 0x6cL /* application + constructed */ |
| 337 | #define LDAP_REQ_MODDN 0x6cL /* application + constructed */ |
| 338 | #define LDAP_REQ_COMPARE 0x6eL /* application + constructed */ |
| 339 | #define LDAP_REQ_ABANDON 0x50L /* application + primitive */ |
| 340 | |
| 341 | /* New defs added for LDAP V3 support */ |
| 342 | #define LDAP_REQ_EXTENDED 0x77L /* application + constructed */ |
| 343 | /* version 3.0 compatibility stuff */ |
| 344 | #define LDAP_REQ_UNBIND_30 0x62L |
| 345 | #define LDAP_REQ_DELETE_30 0x6aL |
| 346 | #define LDAP_REQ_ABANDON_30 0x70L |
| 347 | |
| 348 | /* |
| 349 | * old broken stuff for backwards compatibility - forgot application tag |
| 350 | * and constructed/primitive bit |
| 351 | */ |
| 352 | #define OLD_LDAP_REQ_BIND 0x00L |
| 353 | #define OLD_LDAP_REQ_UNBIND 0x02L |
| 354 | #define OLD_LDAP_REQ_SEARCH 0x03L |
| 355 | #define OLD_LDAP_REQ_MODIFY 0x06L |
| 356 | #define OLD_LDAP_REQ_ADD 0x08L |
| 357 | #define OLD_LDAP_REQ_DELETE 0x0aL |
| 358 | #define OLD_LDAP_REQ_MODRDN 0x0cL |
| 359 | #define OLD_LDAP_REQ_COMPARE 0x0eL |
| 360 | #define OLD_LDAP_REQ_ABANDON 0x10L |
| 361 | |
| 362 | /* possible result types a server can return */ |
| 363 | #define LDAP_RES_BIND 0x61L /* application+constructed+1 */ |
| 364 | #define LDAP_RES_SEARCH_ENTRY 0x64L /* 100 */ |
| 365 | #define LDAP_RES_SEARCH_RESULT 0x65L /* 101 */ |
| 366 | #define LDAP_RES_MODIFY 0x67L /* 103 */ |
| 367 | #define LDAP_RES_ADD 0x69L /* 105 */ |
| 368 | #define LDAP_RES_DELETE 0x6bL /* 107 */ |
| 369 | #define LDAP_RES_MODRDN 0x6dL /* 109 */ |
| 370 | #define LDAP_RES_RENAME 0x6dL /* same as LDAP_RES_MODRDN */ |
| 371 | #define LDAP_RES_COMPARE 0x6fL /* 111 */ |
| 372 | #define LDAP_RES_SEARCH_REFERENCE 0x73L /* 115 */ |
| 373 | #define LDAP_RES_EXTENDED 0x78L /* 120 */ |
| 374 | #define LDAP_RES_ANY (-1L) |
| 375 | |
| 376 | /* old broken stuff for backwards compatibility */ |
| 377 | #define OLD_LDAP_RES_BIND 0x01L |
| 378 | #define OLD_LDAP_RES_SEARCH_ENTRY 0x04L |
| 379 | #define OLD_LDAP_RES_SEARCH_RESULT 0x05L |
| 380 | #define OLD_LDAP_RES_MODIFY 0x07L |
| 381 | #define OLD_LDAP_RES_ADD 0x09L |
| 382 | #define OLD_LDAP_RES_DELETE 0x0bL |
| 383 | #define OLD_LDAP_RES_MODRDN 0x0dL |
| 384 | #define OLD_LDAP_RES_COMPARE 0x0fL |
| 385 | |
| 386 | /* authentication methods available */ |
| 387 | #define LDAP_AUTH_NONE 0x00L /* no authentication */ |
| 388 | #define LDAP_AUTH_SIMPLE 0x80L /* context specific + primitive */ |
| 389 | #define LDAP_AUTH_SASL 0xa3L /* context specific + constructed */ |
| 390 | |
| 391 | /* supported SASL methods */ |
| 392 | #define LDAP_SASL_SIMPLE 0 /* special value used for simple bind */ |
| 393 | #define LDAP_SASL_EXTERNAL "EXTERNAL" |
| 394 | |
| 395 | /* authentication methods supported in v2 */ |
| 396 | #define LDAP_AUTH_KRBV4 0xffL /* means do both of the following */ |
| 397 | #define LDAP_AUTH_KRBV41 0x81L /* context specific + primitive */ |
| 398 | #define LDAP_AUTH_KRBV42 0x82L /* context specific + primitive */ |
| 399 | #define LDAP_AUTH_SASL_V2 0x83L /* context specific + primitive */ |
| 400 | #define LDAP_AUTH_REPL 0x90L /* replication specific */ |
| 401 | |
| 402 | |
| 403 | /* 3.0 compatibility auth methods */ |
| 404 | #define LDAP_AUTH_SIMPLE_30 0xa0L /* context specific + constructed */ |
| 405 | #define LDAP_AUTH_KRBV41_30 0xa1L /* context specific + constructed */ |
| 406 | #define LDAP_AUTH_KRBV42_30 0xa2L /* context specific + constructed */ |
| 407 | #define LDAP_AUTH_SASL_30 0xa3L /* context specific + constructed */ |
| 408 | /* old broken stuff */ |
| 409 | #define OLD_LDAP_AUTH_SIMPLE 0x00L |
| 410 | #define OLD_LDAP_AUTH_KRBV4 0x01L |
| 411 | #define OLD_LDAP_AUTH_KRBV42 0x02L |
| 412 | |
| 413 | /* filter types */ |
| 414 | #define LDAP_FILTER_AND 0xa0L /* context specific + constructed */ |
| 415 | #define LDAP_FILTER_OR 0xa1L /* context specific + constructed */ |
| 416 | #define LDAP_FILTER_NOT 0xa2L /* context specific + constructed */ |
| 417 | #define LDAP_FILTER_EQUALITY 0xa3L /* context specific + constructed */ |
| 418 | #define LDAP_FILTER_SUBSTRINGS 0xa4L /* context specific + constructed */ |
| 419 | #define LDAP_FILTER_GE 0xa5L /* context specific + constructed */ |
| 420 | #define LDAP_FILTER_LE 0xa6L /* context specific + constructed */ |
| 421 | #define LDAP_FILTER_PRESENT 0x87L /* context specific + primitive */ |
| 422 | #define LDAP_FILTER_APPROX 0xa8L /* context specific + constructed */ |
| 423 | |
| 424 | /* 3.0 compatibility filter types */ |
| 425 | #define LDAP_FILTER_PRESENT_30 0xa7L /* context specific + constructed */ |
| 426 | |
| 427 | /* old broken stuff */ |
| 428 | #define OLD_LDAP_FILTER_AND 0x00L |
| 429 | #define OLD_LDAP_FILTER_OR 0x01L |
| 430 | #define OLD_LDAP_FILTER_NOT 0x02L |
| 431 | #define OLD_LDAP_FILTER_EQUALITY 0x03L |
| 432 | #define OLD_LDAP_FILTER_SUBSTRINGS 0x04L |
| 433 | #define OLD_LDAP_FILTER_GE 0x05L |
| 434 | #define OLD_LDAP_FILTER_LE 0x06L |
| 435 | #define OLD_LDAP_FILTER_PRESENT 0x07L |
| 436 | #define OLD_LDAP_FILTER_APPROX 0x08L |
| 437 | |
| 438 | /* substring filter component types */ |
| 439 | #define LDAP_SUBSTRING_INITIAL 0x80L /* context specific */ |
| 440 | #define LDAP_SUBSTRING_ANY 0x81L /* context specific */ |
| 441 | #define LDAP_SUBSTRING_FINAL 0x82L /* context specific */ |
| 442 | |
| 443 | /* 3.0 compatibility substring filter component types */ |
| 444 | #define LDAP_SUBSTRING_INITIAL_30 0xa0L /* context specific */ |
| 445 | #define LDAP_SUBSTRING_ANY_30 0xa1L /* context specific */ |
| 446 | #define LDAP_SUBSTRING_FINAL_30 0xa2L /* context specific */ |
| 447 | |
| 448 | /* old broken stuff */ |
| 449 | #define OLD_LDAP_SUBSTRING_INITIAL 0x00L |
| 450 | #define OLD_LDAP_SUBSTRING_ANY 0x01L |
| 451 | #define OLD_LDAP_SUBSTRING_FINAL 0x02L |
| 452 | |
| 453 | /* search scopes */ |
| 454 | #define LDAP_SCOPE_BASE 0x00 |
| 455 | #define LDAP_SCOPE_ONELEVEL 0x01 |
| 456 | #define LDAP_SCOPE_SUBTREE 0x02 |
| 457 | |
| 458 | /* for modifications */ |
| 459 | typedef struct ldapmod { |
| 460 | int mod_op; |
| 461 | #define LDAP_MOD_ADD 0x00 |
| 462 | #define LDAP_MOD_DELETE 0x01 |
| 463 | #define LDAP_MOD_REPLACE 0x02 |
| 464 | #define LDAP_MOD_BVALUES 0x80 |
| 465 | char *mod_type; |
| 466 | int mod_ver; |
| 467 | char mod_time[48]; |
| 468 | char mod_server[128]; |
| 469 | union { |
| 470 | char **modv_strvals; |
| 471 | struct berval **modv_bvals; |
| 472 | } mod_vals; |
| 473 | struct berval **modv_nvals; |
| 474 | #define mod_values mod_vals.modv_strvals |
| 475 | #define mod_bvalues mod_vals.modv_bvals |
| 476 | #ifdef ONLDAPD |
| 477 | struct ldapmod *mod_next; |
| 478 | int createTombstone; |
| 479 | #endif |
| 480 | } LDAPMod; |
| 481 | |
| 482 | /* |
| 483 | * possible error codes we can return |
| 484 | */ |
| 485 | |
| 486 | #define LDAP_SUCCESS 0x00 |
| 487 | #define GSL_SUCCESS LDAP_SUCCESS |
| 488 | #define LDAP_OPERATIONS_ERROR 0x01 |
| 489 | #define LDAP_PROTOCOL_ERROR 0x02 |
| 490 | #define LDAP_TIMELIMIT_EXCEEDED 0x03 |
| 491 | #define LDAP_SIZELIMIT_EXCEEDED 0x04 |
| 492 | #define LDAP_COMPARE_FALSE 0x05 |
| 493 | #define LDAP_COMPARE_TRUE 0x06 |
| 494 | #define LDAP_STRONG_AUTH_NOT_SUPPORTED 0x07 |
| 495 | #define LDAP_STRONG_AUTH_REQUIRED 0x08 |
| 496 | #define LDAP_PARTIAL_RESULTS 0x09 |
| 497 | #define LDAP_REFERRAL 0x0A |
| 498 | #define LDAP_ADMINLIMIT_EXCEEDED 0x0B |
| 499 | #define LDAP_UNAVAILABLE_CRITICALEXTENSION 0x0C |
| 500 | #define LDAP_CONFIDENTIALITY_REQUIRED 0x0D |
| 501 | #define LDAP_SASL_BIND_IN_PROGRESS 0x0E |
| 502 | |
| 503 | #define LDAP_NO_SUCH_ATTRIBUTE 0x10 |
| 504 | #define LDAP_UNDEFINED_TYPE 0x11 |
| 505 | #define LDAP_INAPPROPRIATE_MATCHING 0x12 |
| 506 | #define LDAP_CONSTRAINT_VIOLATION 0x13 |
| 507 | #define LDAP_TYPE_OR_VALUE_EXISTS 0x14 |
| 508 | #define LDAP_INVALID_SYNTAX 0x15 |
| 509 | |
| 510 | #define LDAP_NO_SUCH_OBJECT 0x20 |
| 511 | #define LDAP_ALIAS_PROBLEM 0x21 |
| 512 | #define LDAP_INVALID_DN_SYNTAX 0x22 |
| 513 | #define LDAP_IS_LEAF 0x23 |
| 514 | #define LDAP_ALIAS_DEREF_PROBLEM 0x24 |
| 515 | |
| 516 | #define NAME_ERROR(n) ((n & 0xf0) == 0x20) |
| 517 | |
| 518 | #define LDAP_INAPPROPRIATE_AUTH 0x30 |
| 519 | #define LDAP_INVALID_CREDENTIALS 0x31 |
| 520 | #define LDAP_INSUFFICIENT_ACCESS 0x32 |
| 521 | #define LDAP_BUSY 0x33 |
| 522 | #define LDAP_UNAVAILABLE 0x34 |
| 523 | #define LDAP_UNWILLING_TO_PERFORM 0x35 |
| 524 | #define LDAP_LOOP_DETECT 0x36 |
| 525 | |
| 526 | #define LDAP_NAMING_VIOLATION 0x40 |
| 527 | #define LDAP_OBJECT_CLASS_VIOLATION 0x41 |
| 528 | #define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 |
| 529 | #define LDAP_NOT_ALLOWED_ON_RDN 0x43 |
| 530 | #define LDAP_ALREADY_EXISTS 0x44 |
| 531 | #define LDAP_NO_OBJECT_CLASS_MODS 0x45 |
| 532 | #define LDAP_RESULTS_TOO_LARGE 0x46 |
| 533 | #define LDAP_AFFECT_MULTIPLE_DSAS 0x47 |
| 534 | |
| 535 | #define LDAP_OTHER 0x50 |
| 536 | #define LDAP_SERVER_DOWN 0x51 |
| 537 | #define LDAP_LOCAL_ERROR 0x52 |
| 538 | #define LDAP_ENCODING_ERROR 0x53 |
| 539 | #define LDAP_DECODING_ERROR 0x54 |
| 540 | #define LDAP_TIMEOUT 0x55 |
| 541 | #define LDAP_AUTH_UNKNOWN 0x56 |
| 542 | #define LDAP_FILTER_ERROR 0x57 |
| 543 | #define LDAP_USER_CANCELLED 0x58 |
| 544 | #define LDAP_PARAM_ERROR 0x59 |
| 545 | #define LDAP_NO_MEMORY 0x5a |
| 546 | #define LDAP_CONNECT_ERROR 0x5b /* 91 */ |
| 547 | #define LDAP_NOT_SUPPORTED 0x5c /* 92 - LDAPv3 */ |
| 548 | #define LDAP_CONTROL_NOT_FOUND 0x5d /* 93 - LDAPv3 */ |
| 549 | #define LDAP_NO_RESULTS_RETURNED 0x5e /* 94 - LDAPv3 */ |
| 550 | #define LDAP_MORE_RESULTS_TO_RETURN 0x5f /* 95 - LDAPv3 */ |
| 551 | #define LDAP_CLIENT_LOOP 0x60 /* 96 - LDAPv3 */ |
| 552 | #define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 /* 97 - LDAPv3 */ |
| 553 | |
| 554 | |
| 555 | /* discover server related error codes */ |
| 556 | #define ORA_LDAP_INFO_NOT_FOUND 500 /* oracle specific error codes */ |
| 557 | #define ORA_LDAP_LOOKUP_ERROR 501 |
| 558 | #define ORA_LDAP_DNS_ADDR_NOT_FOUND 502 |
| 559 | #define ORA_LDAP_FILE_NOT_FOUND 503 |
| 560 | #define ORA_LDAP_FILE_PARSE_ERROR 504 |
| 561 | |
| 562 | /* SSL bind related error codes */ |
| 563 | #define ORA_LDAP_SSL_INITIALIZE_ERROR 550 |
| 564 | #define ORA_LDAP_SSL_CTXCONFIG_ERROR 551 |
| 565 | #define ORA_LDAP_SSL_OPENWALLET_ERROR 552 |
| 566 | #define ORA_LDAP_SSL_CTXCREATE_ERROR 553 |
| 567 | #define ORA_LDAP_SSL_HANDSHAKE_ERROR 554 |
| 568 | #define ORA_LDAP_SSL_PEERCRED_ERROR 555 |
| 569 | |
| 570 | |
| 571 | /* default limit on nesting of referrals */ |
| 572 | #define LDAP_DEFAULT_REFHOPLIMIT 5 |
| 573 | |
| 574 | /* discover server related structs and declarations */ |
| 575 | |
| 576 | /* source from where information can be discovered */ |
| 577 | #define ORA_DNS_DISCOVER 1 |
| 578 | #define ORA_CFGFILE_DISCOVER 2 |
| 579 | #define ORA_AUTO_DISCOVER 3 |
| 580 | |
| 581 | /* method to be applied for obtaining hostname info from DNS */ |
| 582 | #define ORA_USE_INPUT_DN_METHOD 1 |
| 583 | #define ORA_USE_MC_DOMAIN_METHOD 2 |
| 584 | #define ORA_USE_DFLT_LOOKUP_METHOD 4 |
| 585 | #define ORA_USE_ALL_METHODS (ORA_USE_INPUT_DN_METHOD + \ |
| 586 | ORA_USE_MC_DOMAIN_METHOD + \ |
| 587 | ORA_USE_DFLT_LOOKUP_METHOD) |
| 588 | |
| 589 | /* result types */ |
| 590 | #define ORA_DEF_ADMIN_CTXT 1 |
| 591 | #define ORA_DIR_SERVERS 2 |
| 592 | #define ORA_DIR_SERVER_TYPE 3 |
| 593 | #define ORA_ALTDIR_SERVERS 4 |
| 594 | #define ORA_ORCLCOMMCTXMAP 5 |
| 595 | #define ORA_DIRSRVR_CONN_SEC 6 |
| 596 | #define ORA_CFGFL_PATH 7 |
| 597 | |
| 598 | /* properties that can be set in the discovery handle */ |
| 599 | #define ORA_DNS_DN 1 |
| 600 | #define ORA_DNS_DISCOVER_METHOD 2 |
| 601 | #define ORA_SSLMODE 3 |
| 602 | |
| 603 | typedef void * OraLdapHandle; |
| 604 | typedef void * OraResultHandle; |
| 605 | |
| 606 | typedef void OraLdapClientCtx; |
| 607 | |
| 608 | /* Options for SASL credential functions */ |
| 609 | #define ORA_LDAP_SASL_MECH_DIGEST_MD5 "DIGEST-MD5" /* SASL Mechanism : |
| 610 | Digest MD5 */ |
| 611 | #define ORA_LDAP_CRED_HANDLE_SASL_MD5 1 |
| 612 | |
| 613 | /* properties that can be set in Credential handle */ |
| 614 | #define ORA_LDAP_CRED_SASL_REALM 1 |
| 615 | #define ORA_LDAP_CRED_SASL_AUTH_PASSWORD 2 |
| 616 | #define ORA_LDAP_CRED_SASL_AUTHORIZATION_ID 3 |
| 617 | #define ORA_LDAP_CRED_SASL_SECURITY_PROPERTIES 4 |
| 618 | #define ORA_LDAP_CRED_SASL_NORM_AUTHDN 5 |
| 619 | |
| 620 | #define ora_ldap_init_clientctx(ctxptr) ((OraLdapClientCtx **)NULL != (ctxptr) && (*((OraLdapClientCtx **)(ctxptr)) = (OraLdapClientCtx *)NULL,1)) ? LDAP_SUCCESS : LDAP_PARAM_ERROR |
| 621 | |
| 622 | #define ora_ldap_free_clientctx(ctxptr) ((OraLdapClientCtx **)NULL != (ctxptr) && (*((OraLdapClientCtx **)(ctxptr)) = (OraLdapClientCtx *)NULL,1)) ? LDAP_SUCCESS : LDAP_PARAM_ERROR |
| 623 | |
| 624 | /* |
| 625 | * This structure represents both ldap messages and ldap responses. |
| 626 | * These are really the same, except in the case of search responses, |
| 627 | * where a response has multiple messages. |
| 628 | */ |
| 629 | |
| 630 | typedef struct ldapmsg { |
| 631 | int lm_msgid; /* the message id */ |
| 632 | int lm_msgtype; /* the message type */ |
| 633 | BerElement *lm_ber; /* the ber encoded message contents */ |
| 634 | struct ldapmsg *lm_chain; /* for search - next msg in the resp */ |
| 635 | struct ldapmsg *lm_next; /* next response */ |
| 636 | unsigned int lm_time; /* used to maintain cache */ |
| 637 | } LDAPMessage; |
| 638 | #define NULLMSG ((LDAPMessage *) NULL) |
| 639 | |
| 640 | |
| 641 | #ifdef LDAP_REFERRALS |
| 642 | /* |
| 643 | * structure for tracking LDAP server host, ports, DNs, etc. |
| 644 | */ |
| 645 | typedef struct ldap_server { |
| 646 | char *lsrv_host; |
| 647 | char *lsrv_dn; /* if NULL, use default */ |
| 648 | int lsrv_port; |
| 649 | unsigned int lsrv_options; /* boolean options */ |
| 650 | #define LDAP_SRV_OPT_SECURE 0x01 |
| 651 | struct ldap_server *lsrv_next; |
| 652 | } LDAPServer; |
| 653 | |
| 654 | |
| 655 | /* |
| 656 | * structure for representing an LDAP server connection |
| 657 | */ |
| 658 | typedef struct ldap_conn { |
| 659 | Sockbuf *lconn_sb; |
| 660 | BerElement *lconn_ber; /* non-NULL if in midst of msg. */ |
| 661 | int lconn_version; /* LDAP protocol version */ |
| 662 | int lconn_refcnt; |
| 663 | char *lconn_lastused; /* time */ |
| 664 | int lconn_status; |
| 665 | #define LDAP_CONNST_NEEDSOCKET 1 |
| 666 | #define LDAP_CONNST_CONNECTING 2 |
| 667 | #define LDAP_CONNST_CONNECTED 3 |
| 668 | #define LDAP_CONNST_DEAD 4 |
| 669 | LDAPServer *lconn_server; |
| 670 | char *lconn_binddn; /* DN of last successful bind */ |
| 671 | int lconn_bound; /* has a bind been done? */ |
| 672 | char *lconn_krbinstance; |
| 673 | struct ldap_conn *lconn_next; |
| 674 | } LDAPConn; |
| 675 | |
| 676 | |
| 677 | /* |
| 678 | * structure used to track outstanding requests |
| 679 | */ |
| 680 | typedef struct ldapreq { |
| 681 | int lr_msgid; /* the message id */ |
| 682 | int lr_status; /* status of request */ |
| 683 | #define LDAP_REQST_INPROGRESS 1 |
| 684 | #define LDAP_REQST_CHASINGREFS 2 |
| 685 | #define LDAP_REQST_NOTCONNECTED 3 |
| 686 | #define LDAP_REQST_WRITING 4 |
| 687 | int lr_outrefcnt; /* count of outstanding referrals */ |
| 688 | int lr_origid; /* original request's message id */ |
| 689 | int lr_parentcnt; /* count of parent requests */ |
| 690 | int lr_res_msgtype; /* result message type */ |
| 691 | int lr_res_errno; /* result LDAP errno */ |
| 692 | char *lr_res_error; /* result error string */ |
| 693 | char *lr_res_matched;/* result matched DN string */ |
| 694 | BerElement *lr_ber; /* ber encoded request contents */ |
| 695 | LDAPConn *lr_conn; /* connection used to send request */ |
| 696 | char *lr_binddn; /* request is a bind for this DN */ |
| 697 | struct ldapreq *lr_parent; /* request that spawned this referral */ |
| 698 | struct ldapreq *lr_refnext; /* next referral spawned */ |
| 699 | struct ldapreq *lr_prev; /* previous request */ |
| 700 | struct ldapreq *lr_next; /* next request */ |
| 701 | } LDAPRequest; |
| 702 | #endif /* LDAP_REFERRALS */ |
| 703 | |
| 704 | |
| 705 | /* |
| 706 | * structure for client cache |
| 707 | */ |
| 708 | #define LDAP_CACHE_BUCKETS 31 /* cache hash table size */ |
| 709 | typedef struct ldapcache { |
| 710 | LDAPMessage *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */ |
| 711 | LDAPMessage *lc_requests; /* unfulfilled reqs */ |
| 712 | int lc_timeout; /* request timeout */ |
| 713 | int lc_maxmem; /* memory to use */ |
| 714 | int lc_memused; /* memory in use */ |
| 715 | int lc_enabled; /* enabled? */ |
| 716 | unsigned int lc_options; /* options */ |
| 717 | #define LDAP_CACHE_OPT_CACHENOERRS 0x00000001 |
| 718 | #define LDAP_CACHE_OPT_CACHEALLERRS 0x00000002 |
| 719 | } LDAPCache; |
| 720 | #define NULLLDCACHE ((LDAPCache *)NULL) |
| 721 | |
| 722 | /* |
| 723 | * structures for ldap getfilter routines |
| 724 | */ |
| 725 | |
| 726 | typedef struct ldap_filt_info { |
| 727 | char *lfi_filter; |
| 728 | char *lfi_desc; |
| 729 | int lfi_scope; /* LDAP_SCOPE_BASE, etc */ |
| 730 | int lfi_isexact; /* exact match filter? */ |
| 731 | struct ldap_filt_info *lfi_next; |
| 732 | } LDAPFiltInfo; |
| 733 | |
| 734 | typedef struct ldap_filt_list { |
| 735 | char *lfl_tag; |
| 736 | char *lfl_pattern; |
| 737 | char *lfl_delims; |
| 738 | LDAPFiltInfo *lfl_ilist; |
| 739 | struct ldap_filt_list *lfl_next; |
| 740 | } LDAPFiltList; |
| 741 | |
| 742 | |
| 743 | #define LDAP_FILT_MAXSIZ 1024 |
| 744 | |
| 745 | typedef struct ldap_filt_desc { |
| 746 | LDAPFiltList *lfd_filtlist; |
| 747 | LDAPFiltInfo *lfd_curfip; |
| 748 | LDAPFiltInfo lfd_retfi; |
| 749 | char lfd_filter[ LDAP_FILT_MAXSIZ ]; |
| 750 | char *lfd_curval; |
| 751 | char *lfd_curvalcopy; |
| 752 | char **lfd_curvalwords; |
| 753 | char *lfd_filtprefix; |
| 754 | char *lfd_filtsuffix; |
| 755 | } LDAPFiltDesc; |
| 756 | |
| 757 | |
| 758 | typedef struct ldapcontrol { |
| 759 | char *ldctl_oid; |
| 760 | struct berval ldctl_value; |
| 761 | char ldctl_iscritical; |
| 762 | } LDAPControl, *PLDAPControl; |
| 763 | |
| 764 | /* some common controls */ |
| 765 | #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" |
| 766 | |
| 767 | typedef struct ldappend { |
| 768 | void *lp_sema; /* semaphore to post */ |
| 769 | int lp_msgid; /* message id */ |
| 770 | LDAPMessage *lp_result; /* result storage */ |
| 771 | struct ldappend *lp_prev; /* previous pending */ |
| 772 | struct ldappend *lp_next; /* next pending */ |
| 773 | } LDAPPend; |
| 774 | |
| 775 | /* structure for holding credential information - used |
| 776 | * to bind to referred server when chasing referrals |
| 777 | */ |
| 778 | typedef struct ldapcreds { |
| 779 | char *binddn; |
| 780 | char *passwd; |
| 781 | int authmethod; |
| 782 | char *proxyDN; |
| 783 | } LDAPCreds; |
| 784 | |
| 785 | /* |
| 786 | * structure representing an ldap connection |
| 787 | */ |
| 788 | |
| 789 | typedef struct ldap { |
| 790 | Sockbuf ld_sb; /* socket descriptor & buffer */ |
| 791 | char *ld_host; |
| 792 | int ld_version; |
| 793 | char ld_lberoptions; |
| 794 | int ld_deref; |
| 795 | #define LDAP_DEREF_NEVER 0 |
| 796 | #define LDAP_DEREF_SEARCHING 1 |
| 797 | #define LDAP_DEREF_FINDING 2 |
| 798 | #define LDAP_DEREF_ALWAYS 3 |
| 799 | |
| 800 | int ld_timelimit; |
| 801 | int ld_sizelimit; |
| 802 | #define LDAP_NO_LIMIT 0 |
| 803 | |
| 804 | LDAPFiltDesc *ld_filtd; /* from getfilter for ufn searches */ |
| 805 | char *ld_ufnprefix; /* for incomplete ufn's */ |
| 806 | |
| 807 | int ld_errno; |
| 808 | char *ld_error; |
| 809 | char *ld_matched; |
| 810 | int ld_msgid; |
| 811 | |
| 812 | /* do not mess with these */ |
| 813 | #ifdef LDAP_REFERRALS |
| 814 | LDAPRequest *ld_requests; /* list of outstanding requests */ |
| 815 | #else /* LDAP_REFERRALS */ |
| 816 | LDAPMessage *ld_requests; /* list of outstanding requests */ |
| 817 | #endif /* LDAP_REFERRALS */ |
| 818 | LDAPMessage *ld_responses; /* list of outstanding responses */ |
| 819 | int *ld_abandoned; /* array of abandoned requests */ |
| 820 | char ld_attrbuffer[100]; |
| 821 | LDAPCache *ld_cache; /* non-null if cache is initialized */ |
| 822 | char *ld_cldapdn; /* DN used in connectionless search */ |
| 823 | |
| 824 | /* it is OK to change these next four values directly */ |
| 825 | int ld_cldaptries; /* connectionless search retry count */ |
| 826 | int ld_cldaptimeout;/* time between retries */ |
| 827 | int ld_refhoplimit; /* limit on referral nesting */ |
| 828 | unsigned int ld_options; /* boolean options */ |
| 829 | #ifdef LDAP_DNS |
| 830 | #define LDAP_OPT_DNS 0x00000001 /* use DN & DNS */ |
| 831 | #endif /* LDAP_DNS */ |
| 832 | |
| 833 | #define LDAP_BITOPT_REFERRALS 0x80000000 |
| 834 | #define LDAP_BITOPT_SSL 0x40000000 |
| 835 | #define LDAP_BITOPT_DNS 0x20000000 |
| 836 | #define LDAP_BITOPT_RESTART 0x10000000 |
| 837 | #define LDAP_BITOPT_RECONNECT 0x08000000 |
| 838 | #define LDAP_BITOPT_ASYNC 0x04000000 |
| 839 | |
| 840 | /* do not mess with the rest though */ |
| 841 | char *ld_defhost; /* full name of default server */ |
| 842 | int ld_defport; /* port of default server */ |
| 843 | BERTranslateProc ld_lber_encode_translate_proc; |
| 844 | BERTranslateProc ld_lber_decode_translate_proc; |
| 845 | #ifdef LDAP_REFERRALS |
| 846 | LDAPConn *ld_defconn; /* default connection */ |
| 847 | LDAPConn *ld_conns; /* list of server connections */ |
| 848 | void *ld_selectinfo; /* platform specifics for select */ |
| 849 | int (*ld_rebindproc)( struct ldap *ld, char **dnp, |
| 850 | char **passwdp, int *authmethodp, int freeit ); |
| 851 | /* routine to get info needed for re-bind */ |
| 852 | #endif /* LDAP_REFERRALS */ |
| 853 | |
| 854 | /* V3 ldap controls */ |
| 855 | LDAPControl **ld_servercontrol; |
| 856 | LDAPControl **ld_clientcontrol; |
| 857 | |
| 858 | /* Pending results */ |
| 859 | LDAPPend *ld_pend; /* list of pending results */ |
| 860 | |
| 861 | void *gsluctx; /* gslu context handle */ |
| 862 | /* client side referral cache-usage enable/disable option */ |
| 863 | int ld_refcache_enabled; |
| 864 | /* current status of the refcache */ |
| 865 | int ld_refcache_status; |
| 866 | void *ld_refcache; /* client side referral cache */ |
| 867 | void *ld_wrk_selectinfo; |
| 868 | LDAPCreds *ld_creds; /* credential information */ |
| 869 | } LDAP; |
| 870 | |
| 871 | /* |
| 872 | * structure for ldap friendly mapping routines |
| 873 | */ |
| 874 | |
| 875 | typedef struct friendly { |
| 876 | char *f_unfriendly; |
| 877 | char *f_friendly; |
| 878 | } FriendlyMap; |
| 879 | |
| 880 | |
| 881 | /* |
| 882 | * handy macro to check whether LDAP struct is set up for CLDAP or not |
| 883 | */ |
| 884 | #define LDAP_IS_CLDAP( ld ) ( ld->ld_sb.sb_naddr > 0 ) |
| 885 | |
| 886 | |
| 887 | /* |
| 888 | * types for ldap URL handling |
| 889 | */ |
| 890 | typedef struct ldap_url_desc { |
| 891 | char *lud_host; |
| 892 | int lud_port; |
| 893 | char *lud_dn; |
| 894 | char **lud_attrs; |
| 895 | int lud_scope; |
| 896 | char *lud_filter; |
| 897 | char *lud_string; /* for internal use only */ |
| 898 | } LDAPURLDesc; |
| 899 | #define NULLLDAPURLDESC ((LDAPURLDesc *)NULL) |
| 900 | |
| 901 | #define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */ |
| 902 | #define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */ |
| 903 | #define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */ |
| 904 | #define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */ |
| 905 | |
| 906 | /* General Purpose Defines */ |
| 907 | #define GSL_ERR_GENERAL (int)-1 |
| 908 | #define GSL_NULL_TEXT (char *)NULL |
| 909 | |
| 910 | #ifndef LDAPFUNCDECL |
| 911 | #ifdef _WIN32 |
| 912 | #define LDAPFUNCDECL __declspec( dllexport ) |
| 913 | #else /* _WIN32 */ |
| 914 | #define LDAPFUNCDECL |
| 915 | #endif /* _WIN32 */ |
| 916 | #endif /* LDAPFUNCDECL */ |
| 917 | |
| 918 | #if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK) |
| 919 | #include <sys/time.h> |
| 920 | #endif |
| 921 | LDAPFUNCDECL LDAP *ldap_open( char *host, int port ); |
| 922 | LDAPFUNCDECL LDAP *ldap_init( char *defhost, int defport ); |
| 923 | LDAPFUNCDECL int ldap_init_SSL( Sockbuf *,char *, char *,int); |
| 924 | |
| 925 | LDAPFUNCDECL LDAPMessage *ldap_first_entry( LDAP *ld, LDAPMessage *chain ); |
| 926 | LDAPFUNCDECL LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry ); |
| 927 | LDAPFUNCDECL int ldap_count_entries( LDAP *ld, LDAPMessage *chain ); |
| 928 | |
| 929 | LDAPFUNCDECL char *ldap_get_dn( LDAP *ld, LDAPMessage *entry ); |
| 930 | LDAPFUNCDECL char *ldap_dn2ufn( char *dn ); |
| 931 | LDAPFUNCDECL char **ldap_explode_dn( char *dn, int notypes ); |
| 932 | LDAPFUNCDECL char **ldap_explode_dns( char *dn ); |
| 933 | |
| 934 | LDAPFUNCDECL char *ldap_first_attribute( LDAP *ld, LDAPMessage *entry, |
| 935 | BerElement **ber ); |
| 936 | LDAPFUNCDECL char *ldap_next_attribute( LDAP *ld, LDAPMessage *entry, |
| 937 | BerElement *ber ); |
| 938 | |
| 939 | LDAPFUNCDECL char **ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target |
| 940 | ); |
| 941 | LDAPFUNCDECL struct berval **ldap_get_values_len( LDAP *ld, LDAPMessage *entry, |
| 942 | char *target ); |
| 943 | LDAPFUNCDECL int ldap_count_values( char **vals ); |
| 944 | LDAPFUNCDECL int ldap_count_values_len( struct berval **vals ); |
| 945 | LDAPFUNCDECL void ldap_value_free( char **vals ); |
| 946 | LDAPFUNCDECL void ldap_value_free_len( struct berval **vals ); |
| 947 | |
| 948 | LDAPFUNCDECL int ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit ); |
| 949 | LDAPFUNCDECL char *ldap_err2string( int err ); |
| 950 | LDAPFUNCDECL void ldap_perror( LDAP *ld, char *s ); |
| 951 | |
| 952 | LDAPFUNCDECL void ldap_mods_free( LDAPMod **mods, int freemods ); |
| 953 | |
| 954 | LDAPFUNCDECL void ldap_free_friendlymap( FriendlyMap **map ); |
| 955 | |
| 956 | LDAPFUNCDECL int ldap_sort_entries( LDAP *ld, LDAPMessage **chain, char *attr, |
| 957 | int (*cmp)() ); |
| 958 | |
| 959 | LDAPFUNCDECL int ldap_is_ldap_url( char *url ); |
| 960 | LDAPFUNCDECL int ldap_url_parse( char *url, LDAPURLDesc **ludpp ); |
| 961 | LDAPFUNCDECL void ldap_free_urldesc( LDAPURLDesc *ludp ); |
| 962 | LDAPFUNCDECL int ldap_url_search( LDAP *ld, char *url, int attrsonly ); |
| 963 | LDAPFUNCDECL int ldap_url_search_s( LDAP *ld, char *url, int attrsonly, |
| 964 | LDAPMessage **res ); |
| 965 | LDAPFUNCDECL int ldap_url_search_st( LDAP *ld, char *url, int attrsonly, |
| 966 | struct timeval *timeout, LDAPMessage **res ); |
| 967 | |
| 968 | LDAPFUNCDECL int ldap_bind( LDAP *ld, char *who, char *passwd, int authmethod ); |
| 969 | LDAPFUNCDECL int ldap_bind_s( LDAP *ld, char *who, char *cred, int method ); |
| 970 | |
| 971 | LDAPFUNCDECL int ldap_simple_bind( LDAP *ld, char *who, char *passwd ); |
| 972 | LDAPFUNCDECL int ldap_simple_bind_s( LDAP *ld, char *who, char *passwd ); |
| 973 | |
| 974 | LDAPFUNCDECL int ldap_compare( LDAP *ld, char *dn, char *attr, char *value ); |
| 975 | LDAPFUNCDECL int ldap_compare_s( LDAP *ld, char *dn, char *attr, char *value ); |
| 976 | |
| 977 | LDAPFUNCDECL int ldap_delete( LDAP *ld, char *dn ); |
| 978 | LDAPFUNCDECL int ldap_delete_s( LDAP *ld, char *dn ); |
| 979 | |
| 980 | LDAPFUNCDECL int ldap_modify( LDAP *ld, char *dn, LDAPMod **mods ); |
| 981 | LDAPFUNCDECL int ldap_modify_s( LDAP *ld, char *dn, LDAPMod **mods ); |
| 982 | |
| 983 | LDAPFUNCDECL int ldap_modrdn( LDAP *ld, char *dn, char *newrdn ); |
| 984 | LDAPFUNCDECL int ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn ); |
| 985 | LDAPFUNCDECL int ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, |
| 986 | int deleteoldrdn ); |
| 987 | LDAPFUNCDECL int ldap_modrdn2_s( LDAP *ld, char *dn, char *newrdn, |
| 988 | int deleteoldrdn); |
| 989 | |
| 990 | LDAPFUNCDECL int ldap_result( LDAP *ld, int msgid, int all, |
| 991 | struct timeval *timeout, LDAPMessage **result ); |
| 992 | LDAPFUNCDECL int ldap_msgfree( LDAPMessage *lm ); |
| 993 | LDAPFUNCDECL int ldap_msgdelete( LDAP *ld, int msgid ); |
| 994 | LDAPFUNCDECL void ldap_memfree( void *p ); |
| 995 | LDAPFUNCDECL void ber_free( BerElement *ber, int freebuf ); |
| 996 | |
| 997 | LDAPFUNCDECL int ldap_search( LDAP *ld, char *base, int scope, char *filter, |
| 998 | char **attrs, int attrsonly ); |
| 999 | LDAPFUNCDECL int ldap_search_s( LDAP *ld, char *base, int scope, char *filter, |
| 1000 | char **attrs, int attrsonly, LDAPMessage **res ); |
| 1001 | LDAPFUNCDECL int ldap_search_st( LDAP *ld, char *base, int scope, char *filter, |
| 1002 | char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res ); |
| 1003 | |
| 1004 | LDAPFUNCDECL int ldap_unbind( LDAP *ld ); |
| 1005 | LDAPFUNCDECL int ldap_unbind_s( LDAP *ld ); |
| 1006 | |
| 1007 | LDAPFUNCDECL int ldap_abandon( LDAP *ld, int msgid ); |
| 1008 | |
| 1009 | LDAPFUNCDECL int ldap_add( LDAP *ld, char *dn, LDAPMod **attrs ); |
| 1010 | LDAPFUNCDECL int ldap_add_s( LDAP *ld, char *dn, LDAPMod **attrs ); |
| 1011 | |
| 1012 | LDAPFUNCDECL int ldap_rename( LDAP *ld, char *dn, char *newrdn, char *newparent, |
| 1013 | int deleteoldrdn, LDAPControl **serverctrls, |
| 1014 | LDAPControl **clientctrls, int *msgidp); |
| 1015 | LDAPFUNCDECL int ldap_rename_s(LDAP *ld,char *dn,char *newrdn,char *newparent, |
| 1016 | int deleteoldrdn,PLDAPControl *serverctrls, |
| 1017 | PLDAPControl *clientctrls); |
| 1018 | |
| 1019 | LDAPFUNCDECL void ldap_getfilter_free(LDAPFiltDesc *lfdp); |
| 1020 | LDAPFUNCDECL int ldap_abandon_ext( LDAP *ld, int msgid, |
| 1021 | LDAPControl **serverctrls, LDAPControl **clientctrls ); |
| 1022 | |
| 1023 | LDAPFUNCDECL int ldap_add_ext( LDAP *ld, char *dn, LDAPMod **attrs, |
| 1024 | LDAPControl **serverctrls, LDAPControl **clientctrls, |
| 1025 | int *msgidp ); |
| 1026 | LDAPFUNCDECL int ldap_add_ext_s( LDAP *ld, char *dn, LDAPMod **attrs, |
| 1027 | LDAPControl **serverctrls, LDAPControl **clientctrls); |
| 1028 | |
| 1029 | LDAPFUNCDECL int ldap_replic_bind( LDAP *ld, char *dn, char *passwd ); |
| 1030 | LDAPFUNCDECL int ldap_replic_bind_s( LDAP *ld, char *dn, char *passwd ); |
| 1031 | |
| 1032 | LDAPFUNCDECL int ldap_kerberos_bind_s( LDAP *ld, char *who ); |
| 1033 | LDAPFUNCDECL int ldap_kerberos_bind1( LDAP *ld, char *who ); |
| 1034 | LDAPFUNCDECL int ldap_kerberos_bind1_s( LDAP *ld, char *who ); |
| 1035 | LDAPFUNCDECL int ldap_kerberos_bind2( LDAP *ld, char *who ); |
| 1036 | LDAPFUNCDECL int ldap_kerberos_bind2_s( LDAP *ld, char *who ); |
| 1037 | |
| 1038 | LDAPFUNCDECL int ldap_sasl_bind(LDAP * ld, char * dn, char * mechanism, |
| 1039 | struct berval * cred, |
| 1040 | LDAPControl ** serverctrls, |
| 1041 | LDAPControl ** clientctrls, |
| 1042 | int * msgidp); |
| 1043 | LDAPFUNCDECL int ldap_sasl_bind_s(LDAP * ld, char * dn, char * mechanism, |
| 1044 | struct berval * cred, |
| 1045 | LDAPControl ** serverctrls, |
| 1046 | LDAPControl ** clientctrls); |
| 1047 | |
| 1048 | LDAPFUNCDECL int ldap_parse_sasl_bind_result(LDAP * ld, LDAPMessage * res, |
| 1049 | struct berval ** servercredp, |
| 1050 | int freeit); |
| 1051 | |
| 1052 | LDAPFUNCDECL int ldap_native_bind_s(LDAP * ld,char * dn,char * mechanism, |
| 1053 | struct berval * cred, |
| 1054 | unsigned int dir_type); |
| 1055 | |
| 1056 | LDAPFUNCDECL int ldap_compare_ext( LDAP *ld, char *dn, char *attr, |
| 1057 | struct berval *value, LDAPControl **serverctrls, |
| 1058 | LDAPControl **clientctrls, int *msgidp ); |
| 1059 | LDAPFUNCDECL int ldap_compare_ext_s( LDAP *ld, char *dn, char *attr, |
| 1060 | struct berval *value, LDAPControl **serverctrls, |
| 1061 | LDAPControl **clientctrls ); |
| 1062 | |
| 1063 | LDAPFUNCDECL int ldap_delete_ext( LDAP *ld, char *dn, |
| 1064 | LDAPControl **serverctrls, LDAPControl **clientctrls, |
| 1065 | int *msgidp ); |
| 1066 | LDAPFUNCDECL int ldap_delete_ext_s( LDAP *ld, char *dn, |
| 1067 | LDAPControl **serverctrls, LDAPControl **clientctrls ); |
| 1068 | |
| 1069 | LDAPFUNCDECL int ldap_modify_ext( LDAP *ld, char *dn, LDAPMod **mods, |
| 1070 | LDAPControl **serverctrls, LDAPControl **clientctrls, |
| 1071 | int *msgidp ); |
| 1072 | LDAPFUNCDECL int ldap_modify_ext_s( LDAP *ld, char *dn, LDAPMod **mods, |
| 1073 | LDAPControl **serverctrls, LDAPControl **clientctrls ); |
| 1074 | |
| 1075 | |
| 1076 | LDAPFUNCDECL int ldap_get_entry_controls( LDAP *ld, LDAPMessage *entry, |
| 1077 | LDAPControl ***serverctrlsp); |
| 1078 | |
| 1079 | LDAPFUNCDECL char **ldap_explode_rdn( char *dn, int notypes ); |
| 1080 | |
| 1081 | LDAPFUNCDECL int ldap_search_ext ( LDAP *ld, char *base, int scope, |
| 1082 | char *filter, char **attrs, int attrsonly, |
| 1083 | LDAPControl **serverctrls, LDAPControl **clientctrls, |
| 1084 | struct timeval *timeoutp, int sizelimit, int *msgidp ); |
| 1085 | LDAPFUNCDECL int ldap_search_ext_s ( LDAP *ld, char *base, int scope, |
| 1086 | char *filter, char **attrs, int attrsonly, |
| 1087 | LDAPControl **serverctrls, LDAPControl **clientctrls, |
| 1088 | struct timeval *timeoutp, int sizelimit, |
| 1089 | LDAPMessage **res); |
| 1090 | |
| 1091 | LDAPFUNCDECL int ldap_set_option( LDAP *ld, int option, void *optdata ); |
| 1092 | LDAPFUNCDECL int ldap_get_option( LDAP *ld, int option, void *optdata ); |
| 1093 | |
| 1094 | LDAPFUNCDECL void ldap_control_free( LDAPControl *ctrl ); |
| 1095 | LDAPFUNCDECL void ldap_controls_free( LDAPControl **ctrl ); |
| 1096 | |
| 1097 | LDAPFUNCDECL int ldap_msgid( LDAPMessage *lm ); |
| 1098 | LDAPFUNCDECL int ldap_msgtype( LDAPMessage *lm ); |
| 1099 | |
| 1100 | LDAPFUNCDECL LDAPMessage* ldap_next_reference( LDAP *ld, LDAPMessage *res ); |
| 1101 | LDAPFUNCDECL LDAPMessage* ldap_first_reference( LDAP *ld, LDAPMessage *res ); |
| 1102 | LDAPFUNCDECL int ldap_count_references( LDAP *ld, LDAPMessage *res ); |
| 1103 | |
| 1104 | LDAPFUNCDECL LDAPMessage* ldap_first_message( LDAP *ld, LDAPMessage *chain ); |
| 1105 | LDAPFUNCDECL LDAPMessage* ldap_next_message( LDAP *ld, LDAPMessage *chain ); |
| 1106 | LDAPFUNCDECL int ldap_count_messages( LDAP *ld, LDAPMessage *chain ); |
| 1107 | |
| 1108 | LDAPFUNCDECL int ora_ldap_normalize_dn( char *dn, char *normDn); |
| 1109 | LDAPFUNCDECL int ora_ldap_normalize_dn_with_case( char *dn, char *normDn, |
| 1110 | int lower_case); |
| 1111 | |
| 1112 | #ifdef LDAP_REFERRALS |
| 1113 | LDAPFUNCDECL void ldap_set_rebind_proc(LDAP * ld, int (*rebindproc) (LDAP * ld, |
| 1114 | char **dnp, char **passwdp, int *authmethodp, int freeit)); |
| 1115 | LDAPFUNCDECL void ora_ldap_set_rebind_proc(OraLdapClientCtx * clientCtx, |
| 1116 | LDAP * ld, int (*rebindproc) (LDAP * ld, char **dnp, |
| 1117 | char **passwdp, int *authmethodp, int freeit)); |
| 1118 | #endif /*LDAP_REFERRALS*/ |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | /* SASL functions */ |
| 1123 | |
| 1124 | LDAPFUNCDECL int ora_ldap_init_SASL (OraLdapClientCtx *clientCtx, LDAP *ld, |
| 1125 | char * dn, char * mech, void * cred, |
| 1126 | LDAPControl **serverctrls, |
| 1127 | LDAPControl **clientctrls); |
| 1128 | |
| 1129 | LDAPFUNCDECL OraLdapHandle ora_ldap_create_cred_hdl (OraLdapClientCtx *clientCtx,int credType); |
| 1130 | |
| 1131 | LDAPFUNCDECL int ora_ldap_set_cred_props (OraLdapClientCtx * clientCtx, OraLdapHandle cred, |
| 1132 | int propType, void *inProperty); |
| 1133 | |
| 1134 | LDAPFUNCDECL int ora_ldap_get_cred_props (OraLdapClientCtx * clientCtx, OraLdapHandle cred, |
| 1135 | int propType, void *outProperty); |
| 1136 | |
| 1137 | LDAPFUNCDECL int ora_ldap_free_cred_hdl (OraLdapClientCtx * clientCtx, OraLdapHandle cred); |
| 1138 | |
| 1139 | /* LDAP Client Context Functions */ |
| 1140 | |
| 1141 | LDAPFUNCDECL int ora_ldap_create_clientctx(OraLdapClientCtx ** clientCtx); |
| 1142 | |
| 1143 | LDAPFUNCDECL int ora_ldap_set_clientctx(OraLdapClientCtx * clientCtx, |
| 1144 | int property_type, |
| 1145 | void * property); |
| 1146 | |
| 1147 | LDAPFUNCDECL int ora_ldap_destroy_clientctx(OraLdapClientCtx ** clientCtx); |
| 1148 | |
| 1149 | /* |
| 1150 | * discover server functions |
| 1151 | */ |
| 1152 | LDAPFUNCDECL int ora_ldap_discover ( OraLdapHandle hdl, |
| 1153 | OraResultHandle * reshdl); |
| 1154 | LDAPFUNCDECL LDAP *ora_ldap_discover_open( OraLdapHandle hdl); |
| 1155 | |
| 1156 | LDAPFUNCDECL OraLdapHandle ora_create_discov_hdl(int discoveryType); |
| 1157 | |
| 1158 | LDAPFUNCDECL int ora_free_discov_hdl(OraLdapHandle hdl); |
| 1159 | LDAPFUNCDECL int ora_free_result_hdl(OraResultHandle reshdl); |
| 1160 | |
| 1161 | LDAPFUNCDECL int ora_get_result( OraResultHandle reshdl, |
| 1162 | int resType, char *** result); |
| 1163 | |
| 1164 | LDAPFUNCDECL int ora_set_discov_prop( OraLdapHandle hdl, |
| 1165 | int prop, void * inval); |
| 1166 | |
| 1167 | LDAPFUNCDECL int ora_get_discov_prop( OraLdapHandle hdl, |
| 1168 | int prop, void * outval); |
| 1169 | |
| 1170 | |
| 1171 | #if defined(ultrix) || defined( nextstep ) |
| 1172 | extern char *strdup(); |
| 1173 | #endif |
| 1174 | |
| 1175 | #ifdef __cplusplus |
| 1176 | } |
| 1177 | #endif |
| 1178 | #endif |