Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:35:49

0001 /* $OpenLDAP$ */
0002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
0003  * 
0004  * Copyright 1998-2024 The OpenLDAP Foundation.
0005  * All rights reserved.
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted only as authorized by the OpenLDAP
0009  * Public License.
0010  *
0011  * A copy of this license is available in file LICENSE in the
0012  * top-level directory of the distribution or, alternatively, at
0013  * <http://www.OpenLDAP.org/license.html>.
0014  */
0015 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
0016  * All rights reserved.
0017  *
0018  * Redistribution and use in source and binary forms are permitted
0019  * provided that this notice is preserved and that due credit is given
0020  * to the University of Michigan at Ann Arbor. The name of the University
0021  * may not be used to endorse or promote products derived from this
0022  * software without specific prior written permission. This software
0023  * is provided ``as is'' without express or implied warranty.
0024  */
0025 
0026 #ifndef _LDAP_H
0027 #define _LDAP_H
0028 
0029 /* pull in lber */
0030 #include <lber.h>
0031 
0032 /* include version and API feature defines */
0033 #include <ldap_features.h>
0034 
0035 LDAP_BEGIN_DECL
0036 
0037 #define LDAP_VERSION1   1
0038 #define LDAP_VERSION2   2
0039 #define LDAP_VERSION3   3
0040 
0041 #define LDAP_VERSION_MIN    LDAP_VERSION2
0042 #define LDAP_VERSION        LDAP_VERSION2
0043 #define LDAP_VERSION_MAX    LDAP_VERSION3
0044 
0045 /*
0046  * We use 3000+n here because it is above 1823 (for RFC 1823),
0047  * above 2000+rev of IETF LDAPEXT draft (now quite dated),
0048  * yet below allocations for new RFCs (just in case there is
0049  * someday an RFC produced).
0050  */
0051 #define LDAP_API_VERSION    3001
0052 #define LDAP_VENDOR_NAME    "OpenLDAP"
0053 
0054 /* OpenLDAP API Features */
0055 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
0056 
0057 #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT )
0058 #   define  LDAP_API_FEATURE_THREAD_SAFE        1
0059 #endif
0060 #if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE )
0061 #   define  LDAP_API_FEATURE_SESSION_THREAD_SAFE    1
0062 #   define  LDAP_API_FEATURE_OPERATION_THREAD_SAFE  1
0063 #endif
0064 
0065 
0066 #define LDAP_PORT       389     /* ldap:///     default LDAP port */
0067 #define LDAPS_PORT      636     /* ldaps:///    default LDAP over TLS port */
0068 
0069 #define LDAP_ROOT_DSE               ""
0070 #define LDAP_NO_ATTRS               "1.1"
0071 #define LDAP_ALL_USER_ATTRIBUTES    "*"
0072 #define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* RFC 3673 */
0073 
0074 /* RFC 4511:  maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */
0075 #define LDAP_MAXINT (2147483647)
0076 
0077 /*
0078  * LDAP_OPTions
0079  *  0x0000 - 0x0fff reserved for api options
0080  *  0x1000 - 0x3fff reserved for api extended options
0081  *  0x4000 - 0x7fff reserved for private and experimental options
0082  */
0083 
0084 #define LDAP_OPT_API_INFO           0x0000
0085 #define LDAP_OPT_DESC               0x0001 /* historic */
0086 #define LDAP_OPT_DEREF              0x0002
0087 #define LDAP_OPT_SIZELIMIT          0x0003
0088 #define LDAP_OPT_TIMELIMIT          0x0004
0089 /* 0x05 - 0x07 not defined */
0090 #define LDAP_OPT_REFERRALS          0x0008
0091 #define LDAP_OPT_RESTART            0x0009
0092 /* 0x0a - 0x10 not defined */
0093 #define LDAP_OPT_PROTOCOL_VERSION       0x0011
0094 #define LDAP_OPT_SERVER_CONTROLS        0x0012
0095 #define LDAP_OPT_CLIENT_CONTROLS        0x0013
0096 /* 0x14 not defined */
0097 #define LDAP_OPT_API_FEATURE_INFO       0x0015
0098 /* 0x16 - 0x2f not defined */
0099 #define LDAP_OPT_HOST_NAME          0x0030
0100 #define LDAP_OPT_RESULT_CODE            0x0031
0101 #define LDAP_OPT_ERROR_NUMBER           LDAP_OPT_RESULT_CODE
0102 #define LDAP_OPT_DIAGNOSTIC_MESSAGE     0x0032
0103 #define LDAP_OPT_ERROR_STRING           LDAP_OPT_DIAGNOSTIC_MESSAGE
0104 #define LDAP_OPT_MATCHED_DN         0x0033
0105 /* 0x0034 - 0x3fff not defined */
0106 /* 0x0091 used by Microsoft for LDAP_OPT_AUTO_RECONNECT */
0107 #define LDAP_OPT_SSPI_FLAGS         0x0092
0108 /* 0x0093 used by Microsoft for LDAP_OPT_SSL_INFO */
0109 /* 0x0094 used by Microsoft for LDAP_OPT_REF_DEREF_CONN_PER_MSG */
0110 #define LDAP_OPT_SIGN               0x0095
0111 #define LDAP_OPT_ENCRYPT            0x0096
0112 #define LDAP_OPT_SASL_METHOD            0x0097
0113 /* 0x0098 used by Microsoft for LDAP_OPT_AREC_EXCLUSIVE */
0114 #define LDAP_OPT_SECURITY_CONTEXT       0x0099
0115 /* 0x009A used by Microsoft for LDAP_OPT_ROOTDSE_CACHE */
0116 /* 0x009B - 0x3fff not defined */
0117 
0118 /* API Extensions */
0119 #define LDAP_OPT_API_EXTENSION_BASE 0x4000  /* API extensions */
0120 
0121 /* private and experimental options */
0122 /* OpenLDAP specific options */
0123 #define LDAP_OPT_DEBUG_LEVEL        0x5001  /* debug level */
0124 #define LDAP_OPT_TIMEOUT            0x5002  /* default timeout */
0125 #define LDAP_OPT_REFHOPLIMIT        0x5003  /* ref hop limit */
0126 #define LDAP_OPT_NETWORK_TIMEOUT    0x5005  /* socket level timeout */
0127 #define LDAP_OPT_URI                0x5006
0128 #define LDAP_OPT_REFERRAL_URLS      0x5007  /* Referral URLs */
0129 #define LDAP_OPT_SOCKBUF            0x5008  /* sockbuf */
0130 #define LDAP_OPT_DEFBASE        0x5009  /* searchbase */
0131 #define LDAP_OPT_CONNECT_ASYNC      0x5010  /* create connections asynchronously */
0132 #define LDAP_OPT_CONNECT_CB         0x5011  /* connection callbacks */
0133 #define LDAP_OPT_SESSION_REFCNT     0x5012  /* session reference count */
0134 #define LDAP_OPT_KEEPCONN       0x5013  /* keep the connection on read error or NoD */
0135 #define LDAP_OPT_SOCKET_BIND_ADDRESSES  0x5014  /* user configured bind IPs */
0136 #define LDAP_OPT_TCP_USER_TIMEOUT   0x5015  /* set TCP_USER_TIMEOUT if the OS supports it, ignored otherwise */
0137 
0138 /* OpenLDAP TLS options */
0139 #define LDAP_OPT_X_TLS              0x6000
0140 #define LDAP_OPT_X_TLS_CTX          0x6001  /* OpenSSL CTX* */
0141 #define LDAP_OPT_X_TLS_CACERTFILE   0x6002
0142 #define LDAP_OPT_X_TLS_CACERTDIR    0x6003
0143 #define LDAP_OPT_X_TLS_CERTFILE     0x6004
0144 #define LDAP_OPT_X_TLS_KEYFILE      0x6005
0145 #define LDAP_OPT_X_TLS_REQUIRE_CERT 0x6006
0146 #define LDAP_OPT_X_TLS_PROTOCOL_MIN 0x6007
0147 #define LDAP_OPT_X_TLS_CIPHER_SUITE 0x6008
0148 #define LDAP_OPT_X_TLS_RANDOM_FILE  0x6009
0149 #define LDAP_OPT_X_TLS_SSL_CTX      0x600a  /* OpenSSL SSL* */
0150 #define LDAP_OPT_X_TLS_CRLCHECK     0x600b
0151 #define LDAP_OPT_X_TLS_CONNECT_CB   0x600c
0152 #define LDAP_OPT_X_TLS_CONNECT_ARG  0x600d
0153 #define LDAP_OPT_X_TLS_DHFILE       0x600e
0154 #define LDAP_OPT_X_TLS_NEWCTX       0x600f
0155 #define LDAP_OPT_X_TLS_CRLFILE      0x6010  /* GNUtls only */
0156 #define LDAP_OPT_X_TLS_PACKAGE      0x6011
0157 #define LDAP_OPT_X_TLS_ECNAME       0x6012
0158 #define LDAP_OPT_X_TLS_VERSION      0x6013  /* read-only */
0159 #define LDAP_OPT_X_TLS_CIPHER       0x6014  /* read-only */
0160 #define LDAP_OPT_X_TLS_PEERCERT     0x6015  /* read-only */
0161 #define LDAP_OPT_X_TLS_CACERT       0x6016
0162 #define LDAP_OPT_X_TLS_CERT         0x6017
0163 #define LDAP_OPT_X_TLS_KEY          0x6018
0164 #define LDAP_OPT_X_TLS_PEERKEY_HASH 0x6019
0165 #define LDAP_OPT_X_TLS_REQUIRE_SAN  0x601a
0166 #define LDAP_OPT_X_TLS_PROTOCOL_MAX 0x601b
0167 
0168 #define LDAP_OPT_X_TLS_NEVER    0
0169 #define LDAP_OPT_X_TLS_HARD     1
0170 #define LDAP_OPT_X_TLS_DEMAND   2
0171 #define LDAP_OPT_X_TLS_ALLOW    3
0172 #define LDAP_OPT_X_TLS_TRY      4
0173 
0174 #define LDAP_OPT_X_TLS_CRL_NONE 0
0175 #define LDAP_OPT_X_TLS_CRL_PEER 1
0176 #define LDAP_OPT_X_TLS_CRL_ALL  2
0177 
0178 /* for LDAP_OPT_X_TLS_PROTOCOL_MIN/MAX */
0179 #define LDAP_OPT_X_TLS_PROTOCOL(maj,min)    (((maj) << 8) + (min))
0180 #define LDAP_OPT_X_TLS_PROTOCOL_SSL2        (2 << 8)
0181 #define LDAP_OPT_X_TLS_PROTOCOL_SSL3        (3 << 8)
0182 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_0      ((3 << 8) + 1)
0183 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_1      ((3 << 8) + 2)
0184 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_2      ((3 << 8) + 3)
0185 #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_3      ((3 << 8) + 4)
0186 
0187 #define LDAP_OPT_X_SASL_CBINDING_NONE       0
0188 #define LDAP_OPT_X_SASL_CBINDING_TLS_UNIQUE 1
0189 #define LDAP_OPT_X_SASL_CBINDING_TLS_ENDPOINT   2
0190 
0191 /* OpenLDAP SASL options */
0192 #define LDAP_OPT_X_SASL_MECH            0x6100
0193 #define LDAP_OPT_X_SASL_REALM           0x6101
0194 #define LDAP_OPT_X_SASL_AUTHCID         0x6102
0195 #define LDAP_OPT_X_SASL_AUTHZID         0x6103
0196 #define LDAP_OPT_X_SASL_SSF             0x6104 /* read-only */
0197 #define LDAP_OPT_X_SASL_SSF_EXTERNAL    0x6105 /* write-only */
0198 #define LDAP_OPT_X_SASL_SECPROPS        0x6106 /* write-only */
0199 #define LDAP_OPT_X_SASL_SSF_MIN         0x6107
0200 #define LDAP_OPT_X_SASL_SSF_MAX         0x6108
0201 #define LDAP_OPT_X_SASL_MAXBUFSIZE      0x6109
0202 #define LDAP_OPT_X_SASL_MECHLIST        0x610a /* read-only */
0203 #define LDAP_OPT_X_SASL_NOCANON         0x610b
0204 #define LDAP_OPT_X_SASL_USERNAME        0x610c /* read-only */
0205 #define LDAP_OPT_X_SASL_GSS_CREDS       0x610d
0206 #define LDAP_OPT_X_SASL_CBINDING        0x610e
0207 
0208 /*
0209  * OpenLDAP per connection tcp-keepalive settings
0210  * (Linux only, ignored where unsupported)
0211  */
0212 #define LDAP_OPT_X_KEEPALIVE_IDLE       0x6300
0213 #define LDAP_OPT_X_KEEPALIVE_PROBES     0x6301
0214 #define LDAP_OPT_X_KEEPALIVE_INTERVAL   0x6302
0215 
0216 /* Private API Extensions -- reserved for application use */
0217 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000  /* Private API inclusive */
0218 
0219 /*
0220  * ldap_get_option() and ldap_set_option() return values.
0221  * As later versions may return other values indicating
0222  * failure, current applications should only compare returned
0223  * value against LDAP_OPT_SUCCESS.
0224  */
0225 #define LDAP_OPT_SUCCESS    0
0226 #define LDAP_OPT_ERROR      (-1)
0227 
0228 /* option on/off values */
0229 #define LDAP_OPT_ON     ((void *) &ber_pvt_opt_on)
0230 #define LDAP_OPT_OFF    ((void *) 0)
0231 
0232 typedef struct ldapapiinfo {
0233     int     ldapai_info_version;        /* version of LDAPAPIInfo */
0234 #define LDAP_API_INFO_VERSION   (1)
0235     int     ldapai_api_version;         /* revision of API supported */
0236     int     ldapai_protocol_version;    /* highest LDAP version supported */
0237     char    **ldapai_extensions;        /* names of API extensions */
0238     char    *ldapai_vendor_name;        /* name of supplier */
0239     int     ldapai_vendor_version;      /* supplier-specific version * 100 */
0240 } LDAPAPIInfo;
0241 
0242 typedef struct ldap_apifeature_info {
0243     int     ldapaif_info_version;       /* version of LDAPAPIFeatureInfo */
0244 #define LDAP_FEATURE_INFO_VERSION (1)   /* apifeature_info struct version */
0245     char*   ldapaif_name;               /* LDAP_API_FEATURE_* (less prefix) */
0246     int     ldapaif_version;            /* value of LDAP_API_FEATURE_... */
0247 } LDAPAPIFeatureInfo;
0248 
0249 /*
0250  * LDAP Control structure
0251  */
0252 typedef struct ldapcontrol {
0253     char *          ldctl_oid;          /* numericoid of control */
0254     struct berval   ldctl_value;        /* encoded value of control */
0255     char            ldctl_iscritical;   /* criticality */
0256 } LDAPControl;
0257 
0258 /* LDAP Controls */
0259 /*  standard track controls */
0260 #define LDAP_CONTROL_MANAGEDSAIT    "2.16.840.1.113730.3.4.2"  /* RFC 3296 */
0261 #define LDAP_CONTROL_PROXY_AUTHZ    "2.16.840.1.113730.3.4.18" /* RFC 4370 */
0262 #define LDAP_CONTROL_SUBENTRIES     "1.3.6.1.4.1.4203.1.10.1"  /* RFC 3672 */
0263 
0264 #define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3"/* RFC 3876 */
0265 
0266 #define LDAP_CONTROL_ASSERT             "1.3.6.1.1.12"          /* RFC 4528 */
0267 #define LDAP_CONTROL_PRE_READ           "1.3.6.1.1.13.1"        /* RFC 4527 */
0268 #define LDAP_CONTROL_POST_READ          "1.3.6.1.1.13.2"        /* RFC 4527 */
0269 
0270 #define LDAP_CONTROL_SORTREQUEST    "1.2.840.113556.1.4.473" /* RFC 2891 */
0271 #define LDAP_CONTROL_SORTRESPONSE   "1.2.840.113556.1.4.474" /* RFC 2891 */
0272 
0273 /*  non-standard track controls */
0274 #define LDAP_CONTROL_PAGEDRESULTS   "1.2.840.113556.1.4.319"   /* RFC 2696 */
0275 
0276 #define LDAP_CONTROL_AUTHZID_REQUEST    "2.16.840.1.113730.3.4.16"   /* RFC 3829 */
0277 #define LDAP_CONTROL_AUTHZID_RESPONSE   "2.16.840.1.113730.3.4.15"   /* RFC 3829 */
0278 
0279 /* LDAP Content Synchronization Operation -- RFC 4533 */
0280 #define LDAP_SYNC_OID           "1.3.6.1.4.1.4203.1.9.1"
0281 #define LDAP_CONTROL_SYNC       LDAP_SYNC_OID ".1"
0282 #define LDAP_CONTROL_SYNC_STATE LDAP_SYNC_OID ".2"
0283 #define LDAP_CONTROL_SYNC_DONE  LDAP_SYNC_OID ".3"
0284 #define LDAP_SYNC_INFO          LDAP_SYNC_OID ".4"
0285 
0286 #define LDAP_SYNC_NONE                  0x00
0287 #define LDAP_SYNC_REFRESH_ONLY          0x01
0288 #define LDAP_SYNC_RESERVED              0x02
0289 #define LDAP_SYNC_REFRESH_AND_PERSIST   0x03
0290 
0291 #define LDAP_SYNC_REFRESH_PRESENTS      0
0292 #define LDAP_SYNC_REFRESH_DELETES       1
0293 
0294 #define LDAP_TAG_SYNC_NEW_COOKIE        ((ber_tag_t) 0x80U)
0295 #define LDAP_TAG_SYNC_REFRESH_DELETE    ((ber_tag_t) 0xa1U)
0296 #define LDAP_TAG_SYNC_REFRESH_PRESENT   ((ber_tag_t) 0xa2U)
0297 #define LDAP_TAG_SYNC_ID_SET            ((ber_tag_t) 0xa3U)
0298 
0299 #define LDAP_TAG_SYNC_COOKIE            ((ber_tag_t) 0x04U)
0300 #define LDAP_TAG_REFRESHDELETES         ((ber_tag_t) 0x01U)
0301 #define LDAP_TAG_REFRESHDONE            ((ber_tag_t) 0x01U)
0302 #define LDAP_TAG_RELOAD_HINT            ((ber_tag_t) 0x01U)
0303 
0304 #define LDAP_SYNC_PRESENT               0
0305 #define LDAP_SYNC_ADD                   1
0306 #define LDAP_SYNC_MODIFY                2
0307 #define LDAP_SYNC_DELETE                3
0308 #define LDAP_SYNC_NEW_COOKIE            4
0309 
0310 /* LDAP Don't Use Copy Control (RFC 6171) */
0311 #define LDAP_CONTROL_DONTUSECOPY        "1.3.6.1.1.22"
0312 
0313 /* Password policy Controls *//* work in progress */
0314 /* ITS#3458: released; disabled by default */
0315 #define LDAP_CONTROL_PASSWORDPOLICYREQUEST  "1.3.6.1.4.1.42.2.27.8.5.1"
0316 #define LDAP_CONTROL_PASSWORDPOLICYRESPONSE "1.3.6.1.4.1.42.2.27.8.5.1"
0317 
0318 /* various works in progress */
0319 #define LDAP_CONTROL_NOOP               "1.3.6.1.4.1.4203.666.5.2"
0320 #define LDAP_CONTROL_NO_SUBORDINATES    "1.3.6.1.4.1.4203.666.5.11"
0321 #define LDAP_CONTROL_RELAX              "1.3.6.1.4.1.4203.666.5.12"
0322 #define LDAP_CONTROL_MANAGEDIT          LDAP_CONTROL_RELAX
0323 #define LDAP_CONTROL_SLURP              "1.3.6.1.4.1.4203.666.5.13"
0324 #define LDAP_CONTROL_VALSORT            "1.3.6.1.4.1.4203.666.5.14"
0325 #define LDAP_CONTROL_X_DEREF            "1.3.6.1.4.1.4203.666.5.16"
0326 #define LDAP_CONTROL_X_WHATFAILED       "1.3.6.1.4.1.4203.666.5.17"
0327 
0328 /* LDAP Chaining Behavior Control *//* work in progress */
0329 /* <draft-sermersheim-ldap-chaining>;
0330  * see also LDAP_NO_REFERRALS_FOUND, LDAP_CANNOT_CHAIN */
0331 #define LDAP_CONTROL_X_CHAINING_BEHAVIOR    "1.3.6.1.4.1.4203.666.11.3"
0332 
0333 #define LDAP_CHAINING_PREFERRED             0
0334 #define LDAP_CHAINING_REQUIRED              1
0335 #define LDAP_REFERRALS_PREFERRED            2
0336 #define LDAP_REFERRALS_REQUIRED             3
0337 
0338 /* MS Active Directory controls (for compatibility) */
0339 #define LDAP_CONTROL_X_LAZY_COMMIT          "1.2.840.113556.1.4.619"
0340 #define LDAP_CONTROL_X_INCREMENTAL_VALUES   "1.2.840.113556.1.4.802"
0341 #define LDAP_CONTROL_X_DOMAIN_SCOPE         "1.2.840.113556.1.4.1339"
0342 #define LDAP_CONTROL_X_PERMISSIVE_MODIFY    "1.2.840.113556.1.4.1413"
0343 #define LDAP_CONTROL_X_SEARCH_OPTIONS       "1.2.840.113556.1.4.1340"
0344 #define LDAP_SEARCH_FLAG_DOMAIN_SCOPE 1 /* do not generate referrals */
0345 #define LDAP_SEARCH_FLAG_PHANTOM_ROOT 2 /* search all subordinate NCs */
0346 #define LDAP_CONTROL_X_TREE_DELETE      "1.2.840.113556.1.4.805"
0347 
0348 /* MS Active Directory controls - not implemented in slapd(8) */
0349 #define LDAP_CONTROL_X_SERVER_NOTIFICATION  "1.2.840.113556.1.4.528"
0350 #define LDAP_CONTROL_X_EXTENDED_DN      "1.2.840.113556.1.4.529"
0351 #define LDAP_CONTROL_X_SHOW_DELETED     "1.2.840.113556.1.4.417"
0352 #define LDAP_CONTROL_X_DIRSYNC          "1.2.840.113556.1.4.841"
0353 
0354 #define LDAP_CONTROL_X_DIRSYNC_OBJECT_SECURITY      0x00000001
0355 #define LDAP_CONTROL_X_DIRSYNC_ANCESTORS_FIRST      0x00000800
0356 #define LDAP_CONTROL_X_DIRSYNC_PUBLIC_DATA_ONLY     0x00002000
0357 #define LDAP_CONTROL_X_DIRSYNC_INCREMENTAL_VALUES   0x80000000
0358 
0359 
0360 /* <draft-wahl-ldap-session> */
0361 #define LDAP_CONTROL_X_SESSION_TRACKING     "1.3.6.1.4.1.21008.108.63.1"
0362 #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID \
0363                         LDAP_CONTROL_X_SESSION_TRACKING ".1"
0364 #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID \
0365                         LDAP_CONTROL_X_SESSION_TRACKING ".2"
0366 #define LDAP_CONTROL_X_SESSION_TRACKING_USERNAME \
0367                         LDAP_CONTROL_X_SESSION_TRACKING ".3"
0368 /* various expired works */
0369 
0370 /* LDAP Duplicated Entry Control Extension *//* not implemented in slapd(8) */
0371 #define LDAP_CONTROL_DUPENT_REQUEST     "2.16.840.1.113719.1.27.101.1"
0372 #define LDAP_CONTROL_DUPENT_RESPONSE    "2.16.840.1.113719.1.27.101.2"
0373 #define LDAP_CONTROL_DUPENT_ENTRY       "2.16.840.1.113719.1.27.101.3"
0374 #define LDAP_CONTROL_DUPENT LDAP_CONTROL_DUPENT_REQUEST
0375 
0376 /* LDAP Persistent Search Control *//* not implemented in slapd(8) */
0377 #define LDAP_CONTROL_PERSIST_REQUEST                "2.16.840.1.113730.3.4.3"
0378 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE    "2.16.840.1.113730.3.4.7"
0379 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_ADD       0x1
0380 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_DELETE    0x2
0381 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_MODIFY    0x4
0382 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_RENAME    0x8
0383 
0384 /* LDAP VLV */
0385 #define LDAP_CONTROL_VLVREQUEST     "2.16.840.1.113730.3.4.9"
0386 #define LDAP_CONTROL_VLVRESPONSE    "2.16.840.1.113730.3.4.10"
0387 
0388 /* Sun's analogue to ppolicy */
0389 #define LDAP_CONTROL_X_ACCOUNT_USABILITY "1.3.6.1.4.1.42.2.27.9.5.8"
0390 
0391 #define LDAP_TAG_X_ACCOUNT_USABILITY_AVAILABLE  ((ber_tag_t) 0x80U) /* primitive + 0 */
0392 #define LDAP_TAG_X_ACCOUNT_USABILITY_NOT_AVAILABLE  ((ber_tag_t) 0xA1U) /* constructed + 1 */
0393 
0394 #define LDAP_TAG_X_ACCOUNT_USABILITY_INACTIVE   ((ber_tag_t) 0x80U) /* primitive + 0 */
0395 #define LDAP_TAG_X_ACCOUNT_USABILITY_RESET  ((ber_tag_t) 0x81U) /* primitive + 1 */
0396 #define LDAP_TAG_X_ACCOUNT_USABILITY_EXPIRED    ((ber_tag_t) 0x82U) /* primitive + 2 */
0397 #define LDAP_TAG_X_ACCOUNT_USABILITY_REMAINING_GRACE    ((ber_tag_t) 0x83U) /* primitive + 3 */
0398 #define LDAP_TAG_X_ACCOUNT_USABILITY_UNTIL_UNLOCK   ((ber_tag_t) 0x84U) /* primitive + 4 */
0399 
0400 /* Netscape Password policy response controls */
0401 /* <draft-vchu-ldap-pwd-policy> */
0402 #define LDAP_CONTROL_X_PASSWORD_EXPIRED     "2.16.840.1.113730.3.4.4"
0403 #define LDAP_CONTROL_X_PASSWORD_EXPIRING    "2.16.840.1.113730.3.4.5"
0404 
0405 /* LDAP Unsolicited Notifications */
0406 #define LDAP_NOTICE_OF_DISCONNECTION    "1.3.6.1.4.1.1466.20036" /* RFC 4511 */
0407 #define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
0408 
0409 /* LDAP Extended Operations */
0410 #define LDAP_EXOP_START_TLS     "1.3.6.1.4.1.1466.20037"    /* RFC 4511 */
0411 
0412 #define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1"   /* RFC 3062 */
0413 #define LDAP_TAG_EXOP_MODIFY_PASSWD_ID  ((ber_tag_t) 0x80U)
0414 #define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ((ber_tag_t) 0x81U)
0415 #define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U)
0416 #define LDAP_TAG_EXOP_MODIFY_PASSWD_GEN ((ber_tag_t) 0x80U)
0417 
0418 #define LDAP_EXOP_CANCEL        "1.3.6.1.1.8"                   /* RFC 3909 */
0419 #define LDAP_EXOP_X_CANCEL      LDAP_EXOP_CANCEL
0420 
0421 #define LDAP_EXOP_REFRESH       "1.3.6.1.4.1.1466.101.119.1"    /* RFC 2589 */
0422 #define LDAP_TAG_EXOP_REFRESH_REQ_DN    ((ber_tag_t) 0x80U)
0423 #define LDAP_TAG_EXOP_REFRESH_REQ_TTL   ((ber_tag_t) 0x81U)
0424 #define LDAP_TAG_EXOP_REFRESH_RES_TTL   ((ber_tag_t) 0x81U)
0425 
0426 #define LDAP_EXOP_VERIFY_CREDENTIALS    "1.3.6.1.4.1.4203.666.6.5"
0427 #define LDAP_EXOP_X_VERIFY_CREDENTIALS  LDAP_EXOP_VERIFY_CREDENTIALS
0428 
0429 #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_COOKIE  ((ber_tag_t) 0x80U)
0430 #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_SCREDS  ((ber_tag_t) 0x81U)
0431 #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_CONTROLS ((ber_tag_t) 0xa2U) /* context specific + constructed + 2 */
0432 
0433 #define LDAP_EXOP_WHO_AM_I      "1.3.6.1.4.1.4203.1.11.3"       /* RFC 4532 */
0434 #define LDAP_EXOP_X_WHO_AM_I    LDAP_EXOP_WHO_AM_I
0435 
0436 /* various works in progress */
0437 #define LDAP_EXOP_TURN      "1.3.6.1.1.19"              /* RFC 4531 */
0438 #define LDAP_EXOP_X_TURN    LDAP_EXOP_TURN
0439 
0440 /* LDAP Distributed Procedures <draft-sermersheim-ldap-distproc> */
0441 /* a work in progress */
0442 #define LDAP_X_DISTPROC_BASE        "1.3.6.1.4.1.4203.666.11.6"
0443 #define LDAP_EXOP_X_CHAINEDREQUEST  LDAP_X_DISTPROC_BASE ".1"
0444 #define LDAP_FEATURE_X_CANCHAINOPS  LDAP_X_DISTPROC_BASE ".2"
0445 #define LDAP_CONTROL_X_RETURNCONTREF    LDAP_X_DISTPROC_BASE ".3"
0446 #define LDAP_URLEXT_X_LOCALREFOID   LDAP_X_DISTPROC_BASE ".4"
0447 #define LDAP_URLEXT_X_REFTYPEOID    LDAP_X_DISTPROC_BASE ".5"
0448 #define LDAP_URLEXT_X_SEARCHEDSUBTREEOID \
0449                     LDAP_X_DISTPROC_BASE ".6"
0450 #define LDAP_URLEXT_X_FAILEDNAMEOID LDAP_X_DISTPROC_BASE ".7"
0451 #define LDAP_URLEXT_X_LOCALREF      "x-localReference"
0452 #define LDAP_URLEXT_X_REFTYPE       "x-referenceType"
0453 #define LDAP_URLEXT_X_SEARCHEDSUBTREE   "x-searchedSubtree"
0454 #define LDAP_URLEXT_X_FAILEDNAME    "x-failedName"
0455 
0456 #define LDAP_TXN                        "1.3.6.1.1.21" /* RFC 5805 */
0457 #define LDAP_EXOP_TXN_START             LDAP_TXN ".1"
0458 #define LDAP_CONTROL_TXN_SPEC           LDAP_TXN ".2"
0459 #define LDAP_EXOP_TXN_END               LDAP_TXN ".3"
0460 #define LDAP_EXOP_TXN_ABORTED_NOTICE    LDAP_TXN ".4"
0461 
0462 /* LDAP Features */
0463 #define LDAP_FEATURE_ALL_OP_ATTRS   "1.3.6.1.4.1.4203.1.5.1"    /* RFC 3673 */
0464 #define LDAP_FEATURE_OBJECTCLASS_ATTRS \
0465     "1.3.6.1.4.1.4203.1.5.2" /*  @objectClass - new number to be assigned */
0466 #define LDAP_FEATURE_ABSOLUTE_FILTERS "1.3.6.1.4.1.4203.1.5.3"  /* (&) (|) */
0467 #define LDAP_FEATURE_LANGUAGE_TAG_OPTIONS "1.3.6.1.4.1.4203.1.5.4"
0468 #define LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS "1.3.6.1.4.1.4203.1.5.5"
0469 #define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.1.14"
0470 
0471 /* LDAP Experimental (works in progress) Features */
0472 #define LDAP_FEATURE_SUBORDINATE_SCOPE \
0473     "1.3.6.1.4.1.4203.666.8.1" /* "children" */
0474 #define LDAP_FEATURE_CHILDREN_SCOPE LDAP_FEATURE_SUBORDINATE_SCOPE
0475 
0476 /*
0477  * specific LDAP instantiations of BER types we know about
0478  */
0479 
0480 /* Overview of LBER tag construction
0481  *
0482  *  Bits
0483  *  ______
0484  *  8 7 | CLASS
0485  *  0 0 = UNIVERSAL
0486  *  0 1 = APPLICATION
0487  *  1 0 = CONTEXT-SPECIFIC
0488  *  1 1 = PRIVATE
0489  *      _____
0490  *      | 6 | DATA-TYPE
0491  *        0 = PRIMITIVE
0492  *        1 = CONSTRUCTED
0493  *          ___________
0494  *          | 5 ... 1 | TAG-NUMBER
0495  */
0496 
0497 /* general stuff */
0498 #define LDAP_TAG_MESSAGE    ((ber_tag_t) 0x30U) /* constructed + 16 */
0499 #define LDAP_TAG_MSGID      ((ber_tag_t) 0x02U) /* integer */
0500 
0501 #define LDAP_TAG_LDAPDN     ((ber_tag_t) 0x04U) /* octet string */
0502 #define LDAP_TAG_LDAPCRED   ((ber_tag_t) 0x04U) /* octet string */
0503 
0504 #define LDAP_TAG_CONTROLS   ((ber_tag_t) 0xa0U) /* context specific + constructed + 0 */
0505 #define LDAP_TAG_REFERRAL   ((ber_tag_t) 0xa3U) /* context specific + constructed + 3 */
0506 
0507 #define LDAP_TAG_NEWSUPERIOR    ((ber_tag_t) 0x80U) /* context-specific + primitive + 0 */
0508 
0509 #define LDAP_TAG_EXOP_REQ_OID   ((ber_tag_t) 0x80U) /* context specific + primitive */
0510 #define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */
0511 #define LDAP_TAG_EXOP_RES_OID   ((ber_tag_t) 0x8aU) /* context specific + primitive */
0512 #define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU) /* context specific + primitive */
0513 
0514 #define LDAP_TAG_IM_RES_OID   ((ber_tag_t) 0x80U)   /* context specific + primitive */
0515 #define LDAP_TAG_IM_RES_VALUE ((ber_tag_t) 0x81U)   /* context specific + primitive */
0516 
0517 #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U) /* context specific + primitive */
0518 
0519 /* LDAP Request Messages */
0520 #define LDAP_REQ_BIND       ((ber_tag_t) 0x60U) /* application + constructed */
0521 #define LDAP_REQ_UNBIND     ((ber_tag_t) 0x42U) /* application + primitive   */
0522 #define LDAP_REQ_SEARCH     ((ber_tag_t) 0x63U) /* application + constructed */
0523 #define LDAP_REQ_MODIFY     ((ber_tag_t) 0x66U) /* application + constructed */
0524 #define LDAP_REQ_ADD        ((ber_tag_t) 0x68U) /* application + constructed */
0525 #define LDAP_REQ_DELETE     ((ber_tag_t) 0x4aU) /* application + primitive   */
0526 #define LDAP_REQ_MODDN      ((ber_tag_t) 0x6cU) /* application + constructed */
0527 #define LDAP_REQ_MODRDN     LDAP_REQ_MODDN
0528 #define LDAP_REQ_RENAME     LDAP_REQ_MODDN
0529 #define LDAP_REQ_COMPARE    ((ber_tag_t) 0x6eU) /* application + constructed */
0530 #define LDAP_REQ_ABANDON    ((ber_tag_t) 0x50U) /* application + primitive   */
0531 #define LDAP_REQ_EXTENDED   ((ber_tag_t) 0x77U) /* application + constructed */
0532 
0533 /* LDAP Response Messages */
0534 #define LDAP_RES_BIND       ((ber_tag_t) 0x61U) /* application + constructed */
0535 #define LDAP_RES_SEARCH_ENTRY   ((ber_tag_t) 0x64U) /* application + constructed */
0536 #define LDAP_RES_SEARCH_REFERENCE   ((ber_tag_t) 0x73U) /* V3: application + constructed */
0537 #define LDAP_RES_SEARCH_RESULT  ((ber_tag_t) 0x65U) /* application + constructed */
0538 #define LDAP_RES_MODIFY     ((ber_tag_t) 0x67U) /* application + constructed */
0539 #define LDAP_RES_ADD        ((ber_tag_t) 0x69U) /* application + constructed */
0540 #define LDAP_RES_DELETE     ((ber_tag_t) 0x6bU) /* application + constructed */
0541 #define LDAP_RES_MODDN      ((ber_tag_t) 0x6dU) /* application + constructed */
0542 #define LDAP_RES_MODRDN     LDAP_RES_MODDN  /* application + constructed */
0543 #define LDAP_RES_RENAME     LDAP_RES_MODDN  /* application + constructed */
0544 #define LDAP_RES_COMPARE    ((ber_tag_t) 0x6fU) /* application + constructed */
0545 #define LDAP_RES_EXTENDED   ((ber_tag_t) 0x78U) /* V3: application + constructed */
0546 #define LDAP_RES_INTERMEDIATE   ((ber_tag_t) 0x79U) /* V3+: application + constructed */
0547 
0548 #define LDAP_RES_ANY            (-1)
0549 #define LDAP_RES_UNSOLICITED    (0)
0550 
0551 
0552 /* sasl methods */
0553 #define LDAP_SASL_SIMPLE    ((char*)0)
0554 #define LDAP_SASL_NULL      ("")
0555 
0556 
0557 /* authentication methods available */
0558 #define LDAP_AUTH_NONE   ((ber_tag_t) 0x00U) /* no authentication */
0559 #define LDAP_AUTH_SIMPLE ((ber_tag_t) 0x80U) /* context specific + primitive */
0560 #define LDAP_AUTH_SASL   ((ber_tag_t) 0xa3U) /* context specific + constructed */
0561 #define LDAP_AUTH_KRBV4  ((ber_tag_t) 0xffU) /* means do both of the following */
0562 #define LDAP_AUTH_KRBV41 ((ber_tag_t) 0x81U) /* context specific + primitive */
0563 #define LDAP_AUTH_KRBV42 ((ber_tag_t) 0x82U) /* context specific + primitive */
0564 
0565 /* used by the Windows API but not used on the wire */
0566 #define LDAP_AUTH_NEGOTIATE ((ber_tag_t) 0x04FFU)
0567 
0568 /* filter types */
0569 #define LDAP_FILTER_AND ((ber_tag_t) 0xa0U) /* context specific + constructed */
0570 #define LDAP_FILTER_OR  ((ber_tag_t) 0xa1U) /* context specific + constructed */
0571 #define LDAP_FILTER_NOT ((ber_tag_t) 0xa2U) /* context specific + constructed */
0572 #define LDAP_FILTER_EQUALITY ((ber_tag_t) 0xa3U) /* context specific + constructed */
0573 #define LDAP_FILTER_SUBSTRINGS ((ber_tag_t) 0xa4U) /* context specific + constructed */
0574 #define LDAP_FILTER_GE ((ber_tag_t) 0xa5U) /* context specific + constructed */
0575 #define LDAP_FILTER_LE ((ber_tag_t) 0xa6U) /* context specific + constructed */
0576 #define LDAP_FILTER_PRESENT ((ber_tag_t) 0x87U) /* context specific + primitive   */
0577 #define LDAP_FILTER_APPROX ((ber_tag_t) 0xa8U)  /* context specific + constructed */
0578 #define LDAP_FILTER_EXT ((ber_tag_t) 0xa9U) /* context specific + constructed */
0579 
0580 /* extended filter component types */
0581 #define LDAP_FILTER_EXT_OID     ((ber_tag_t) 0x81U) /* context specific */
0582 #define LDAP_FILTER_EXT_TYPE    ((ber_tag_t) 0x82U) /* context specific */
0583 #define LDAP_FILTER_EXT_VALUE   ((ber_tag_t) 0x83U) /* context specific */
0584 #define LDAP_FILTER_EXT_DNATTRS ((ber_tag_t) 0x84U) /* context specific */
0585 
0586 /* substring filter component types */
0587 #define LDAP_SUBSTRING_INITIAL  ((ber_tag_t) 0x80U) /* context specific */
0588 #define LDAP_SUBSTRING_ANY      ((ber_tag_t) 0x81U) /* context specific */
0589 #define LDAP_SUBSTRING_FINAL    ((ber_tag_t) 0x82U) /* context specific */
0590 
0591 /* search scopes */
0592 #define LDAP_SCOPE_BASE         ((ber_int_t) 0x0000)
0593 #define LDAP_SCOPE_BASEOBJECT   LDAP_SCOPE_BASE
0594 #define LDAP_SCOPE_ONELEVEL     ((ber_int_t) 0x0001)
0595 #define LDAP_SCOPE_ONE          LDAP_SCOPE_ONELEVEL
0596 #define LDAP_SCOPE_SUBTREE      ((ber_int_t) 0x0002)
0597 #define LDAP_SCOPE_SUB          LDAP_SCOPE_SUBTREE
0598 #define LDAP_SCOPE_SUBORDINATE  ((ber_int_t) 0x0003) /* OpenLDAP extension */
0599 #define LDAP_SCOPE_CHILDREN     LDAP_SCOPE_SUBORDINATE
0600 #define LDAP_SCOPE_DEFAULT      ((ber_int_t) -1)     /* OpenLDAP extension */
0601 
0602 /* substring filter component types */
0603 #define LDAP_SUBSTRING_INITIAL  ((ber_tag_t) 0x80U) /* context specific */
0604 #define LDAP_SUBSTRING_ANY      ((ber_tag_t) 0x81U) /* context specific */
0605 #define LDAP_SUBSTRING_FINAL    ((ber_tag_t) 0x82U) /* context specific */
0606 
0607 /*
0608  * LDAP Result Codes
0609  */
0610 #define LDAP_SUCCESS                0x00
0611 
0612 #define LDAP_RANGE(n,x,y)   (((x) <= (n)) && ((n) <= (y)))
0613 
0614 #define LDAP_OPERATIONS_ERROR       0x01
0615 #define LDAP_PROTOCOL_ERROR         0x02
0616 #define LDAP_TIMELIMIT_EXCEEDED     0x03
0617 #define LDAP_SIZELIMIT_EXCEEDED     0x04
0618 #define LDAP_COMPARE_FALSE          0x05
0619 #define LDAP_COMPARE_TRUE           0x06
0620 #define LDAP_AUTH_METHOD_NOT_SUPPORTED  0x07
0621 #define LDAP_STRONG_AUTH_NOT_SUPPORTED  LDAP_AUTH_METHOD_NOT_SUPPORTED
0622 #define LDAP_STRONG_AUTH_REQUIRED   0x08
0623 #define LDAP_STRONGER_AUTH_REQUIRED LDAP_STRONG_AUTH_REQUIRED
0624 #define LDAP_PARTIAL_RESULTS        0x09    /* LDAPv2+ (not LDAPv3) */
0625 
0626 #define LDAP_REFERRAL               0x0a /* LDAPv3 */
0627 #define LDAP_ADMINLIMIT_EXCEEDED    0x0b /* LDAPv3 */
0628 #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* LDAPv3 */
0629 #define LDAP_CONFIDENTIALITY_REQUIRED   0x0d /* LDAPv3 */
0630 #define LDAP_SASL_BIND_IN_PROGRESS  0x0e /* LDAPv3 */
0631 
0632 #define LDAP_ATTR_ERROR(n)  LDAP_RANGE((n),0x10,0x15) /* 16-21 */
0633 
0634 #define LDAP_NO_SUCH_ATTRIBUTE      0x10
0635 #define LDAP_UNDEFINED_TYPE         0x11
0636 #define LDAP_INAPPROPRIATE_MATCHING 0x12
0637 #define LDAP_CONSTRAINT_VIOLATION   0x13
0638 #define LDAP_TYPE_OR_VALUE_EXISTS   0x14
0639 #define LDAP_INVALID_SYNTAX         0x15
0640 
0641 #define LDAP_NAME_ERROR(n)  LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
0642 
0643 #define LDAP_NO_SUCH_OBJECT         0x20
0644 #define LDAP_ALIAS_PROBLEM          0x21
0645 #define LDAP_INVALID_DN_SYNTAX      0x22
0646 #define LDAP_IS_LEAF                0x23 /* not LDAPv3 */
0647 #define LDAP_ALIAS_DEREF_PROBLEM    0x24
0648 
0649 #define LDAP_SECURITY_ERROR(n)  LDAP_RANGE((n),0x2F,0x32) /* 47-50 */
0650 
0651 #define LDAP_X_PROXY_AUTHZ_FAILURE  0x2F /* LDAPv3 proxy authorization */
0652 #define LDAP_INAPPROPRIATE_AUTH     0x30
0653 #define LDAP_INVALID_CREDENTIALS    0x31
0654 #define LDAP_INSUFFICIENT_ACCESS    0x32
0655 
0656 #define LDAP_SERVICE_ERROR(n)   LDAP_RANGE((n),0x33,0x36) /* 51-54 */
0657 
0658 #define LDAP_BUSY                   0x33
0659 #define LDAP_UNAVAILABLE            0x34
0660 #define LDAP_UNWILLING_TO_PERFORM   0x35
0661 #define LDAP_LOOP_DETECT            0x36
0662 
0663 #define LDAP_UPDATE_ERROR(n)    LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
0664 
0665 #define LDAP_NAMING_VIOLATION       0x40
0666 #define LDAP_OBJECT_CLASS_VIOLATION 0x41
0667 #define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42
0668 #define LDAP_NOT_ALLOWED_ON_RDN     0x43
0669 #define LDAP_ALREADY_EXISTS         0x44
0670 #define LDAP_NO_OBJECT_CLASS_MODS   0x45
0671 #define LDAP_RESULTS_TOO_LARGE      0x46 /* CLDAP */
0672 #define LDAP_AFFECTS_MULTIPLE_DSAS  0x47
0673 
0674 #define LDAP_VLV_ERROR              0x4C
0675 
0676 #define LDAP_OTHER                  0x50
0677 
0678 /* LCUP operation codes (113-117) - not implemented */
0679 #define LDAP_CUP_RESOURCES_EXHAUSTED    0x71
0680 #define LDAP_CUP_SECURITY_VIOLATION     0x72
0681 #define LDAP_CUP_INVALID_DATA           0x73
0682 #define LDAP_CUP_UNSUPPORTED_SCHEME     0x74
0683 #define LDAP_CUP_RELOAD_REQUIRED        0x75
0684 
0685 /* Cancel operation codes (118-121) */
0686 #define LDAP_CANCELLED              0x76
0687 #define LDAP_NO_SUCH_OPERATION      0x77
0688 #define LDAP_TOO_LATE               0x78
0689 #define LDAP_CANNOT_CANCEL          0x79
0690 
0691 /* Assertion control (122) */ 
0692 #define LDAP_ASSERTION_FAILED       0x7A
0693 
0694 /* Proxied Authorization Denied (123) */ 
0695 #define LDAP_PROXIED_AUTHORIZATION_DENIED       0x7B
0696 
0697 /* Experimental result codes */
0698 #define LDAP_E_ERROR(n) LDAP_RANGE((n),0x1000,0x3FFF)
0699 
0700 /* LDAP Sync (4096) */
0701 #define LDAP_SYNC_REFRESH_REQUIRED      0x1000
0702 
0703 
0704 /* Private Use result codes */
0705 #define LDAP_X_ERROR(n) LDAP_RANGE((n),0x4000,0xFFFF)
0706 
0707 #define LDAP_X_SYNC_REFRESH_REQUIRED    0x4100 /* defunct */
0708 #define LDAP_X_ASSERTION_FAILED         0x410f /* defunct */
0709 
0710 /* for the LDAP No-Op control */
0711 #define LDAP_X_NO_OPERATION             0x410e
0712 
0713 /* for the Chaining Behavior control (consecutive result codes requested;
0714  * see <draft-sermersheim-ldap-chaining> ) */
0715 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
0716 #define LDAP_X_NO_REFERRALS_FOUND       0x4110
0717 #define LDAP_X_CANNOT_CHAIN         0x4111
0718 #endif
0719 
0720 /* for Distributed Procedures (see <draft-sermersheim-ldap-distproc>) */
0721 #ifdef LDAP_X_DISTPROC_BASE
0722 #define LDAP_X_INVALIDREFERENCE         0x4112
0723 #endif
0724 
0725 #define LDAP_TXN_SPECIFY_OKAY       0x4120
0726 #define LDAP_TXN_ID_INVALID         0x4121
0727 
0728 /* API Error Codes
0729  *
0730  * Based on draft-ietf-ldap-c-api-xx
0731  * but with new negative code values
0732  */
0733 #define LDAP_API_ERROR(n)       ((n)<0)
0734 #define LDAP_API_RESULT(n)      ((n)<=0)
0735 
0736 #define LDAP_SERVER_DOWN                (-1)
0737 #define LDAP_LOCAL_ERROR                (-2)
0738 #define LDAP_ENCODING_ERROR             (-3)
0739 #define LDAP_DECODING_ERROR             (-4)
0740 #define LDAP_TIMEOUT                    (-5)
0741 #define LDAP_AUTH_UNKNOWN               (-6)
0742 #define LDAP_FILTER_ERROR               (-7)
0743 #define LDAP_USER_CANCELLED             (-8)
0744 #define LDAP_PARAM_ERROR                (-9)
0745 #define LDAP_NO_MEMORY                  (-10)
0746 #define LDAP_CONNECT_ERROR              (-11)
0747 #define LDAP_NOT_SUPPORTED              (-12)
0748 #define LDAP_CONTROL_NOT_FOUND          (-13)
0749 #define LDAP_NO_RESULTS_RETURNED        (-14)
0750 #define LDAP_MORE_RESULTS_TO_RETURN     (-15)   /* Obsolete */
0751 #define LDAP_CLIENT_LOOP                (-16)
0752 #define LDAP_REFERRAL_LIMIT_EXCEEDED    (-17)
0753 #define LDAP_X_CONNECTING           (-18)
0754 
0755 
0756 /*
0757  * This structure represents both ldap messages and ldap responses.
0758  * These are really the same, except in the case of search responses,
0759  * where a response has multiple messages.
0760  */
0761 
0762 typedef struct ldapmsg LDAPMessage;
0763 
0764 /* for modifications */
0765 typedef struct ldapmod {
0766     int     mod_op;
0767 
0768 #define LDAP_MOD_OP         (0x0007)
0769 #define LDAP_MOD_ADD        (0x0000)
0770 #define LDAP_MOD_DELETE     (0x0001)
0771 #define LDAP_MOD_REPLACE    (0x0002)
0772 #define LDAP_MOD_INCREMENT  (0x0003) /* OpenLDAP extension */
0773 #define LDAP_MOD_BVALUES    (0x0080)
0774 /* IMPORTANT: do not use code 0x1000 (or above),
0775  * it is used internally by the backends!
0776  * (see ldap/servers/slapd/slap.h)
0777  */
0778 
0779     char        *mod_type;
0780     union mod_vals_u {
0781         char        **modv_strvals;
0782         struct berval   **modv_bvals;
0783     } mod_vals;
0784 #define mod_values  mod_vals.modv_strvals
0785 #define mod_bvalues mod_vals.modv_bvals
0786 } LDAPMod;
0787 
0788 /*
0789  * structure representing an ldap session which can
0790  * encompass connections to multiple servers (in the
0791  * face of referrals).
0792  */
0793 typedef struct ldap LDAP;
0794 
0795 #define LDAP_DEREF_NEVER        0x00
0796 #define LDAP_DEREF_SEARCHING    0x01
0797 #define LDAP_DEREF_FINDING      0x02
0798 #define LDAP_DEREF_ALWAYS       0x03
0799 
0800 #define LDAP_NO_LIMIT           0
0801 
0802 /* how many messages to retrieve results for */
0803 #define LDAP_MSG_ONE            0x00
0804 #define LDAP_MSG_ALL            0x01
0805 #define LDAP_MSG_RECEIVED       0x02
0806 
0807 /*
0808  * types for ldap URL handling
0809  */
0810 typedef struct ldap_url_desc {
0811     struct ldap_url_desc *lud_next;
0812     char    *lud_scheme;
0813     char    *lud_host;
0814     int     lud_port;
0815     char    *lud_dn;
0816     char    **lud_attrs;
0817     int     lud_scope;
0818     char    *lud_filter;
0819     char    **lud_exts;
0820     int     lud_crit_exts;
0821 } LDAPURLDesc;
0822 
0823 #define LDAP_URL_SUCCESS        0x00    /* Success */
0824 #define LDAP_URL_ERR_MEM        0x01    /* can't allocate memory space */
0825 #define LDAP_URL_ERR_PARAM      0x02    /* parameter is bad */
0826 
0827 #define LDAP_URL_ERR_BADSCHEME  0x03    /* URL doesn't begin with "ldap[si]://" */
0828 #define LDAP_URL_ERR_BADENCLOSURE 0x04  /* URL is missing trailing ">" */
0829 #define LDAP_URL_ERR_BADURL     0x05    /* URL is bad */
0830 #define LDAP_URL_ERR_BADHOST    0x06    /* host port is bad */
0831 #define LDAP_URL_ERR_BADATTRS   0x07    /* bad (or missing) attributes */
0832 #define LDAP_URL_ERR_BADSCOPE   0x08    /* scope string is invalid (or missing) */
0833 #define LDAP_URL_ERR_BADFILTER  0x09    /* bad or missing filter */
0834 #define LDAP_URL_ERR_BADEXTS    0x0a    /* bad or missing extensions */
0835 
0836 /*
0837  * LDAP sync (RFC4533) API
0838  */
0839 
0840 typedef struct ldap_sync_t ldap_sync_t;
0841 
0842 typedef enum {
0843     /* these are private - the client should never see them */
0844     LDAP_SYNC_CAPI_NONE     = -1,
0845 
0846     LDAP_SYNC_CAPI_PHASE_FLAG   = 0x10U,
0847     LDAP_SYNC_CAPI_IDSET_FLAG   = 0x20U,
0848     LDAP_SYNC_CAPI_DONE_FLAG    = 0x40U,
0849 
0850     /* these are passed to ls_search_entry() */
0851     LDAP_SYNC_CAPI_PRESENT      = LDAP_SYNC_PRESENT,
0852     LDAP_SYNC_CAPI_ADD      = LDAP_SYNC_ADD,
0853     LDAP_SYNC_CAPI_MODIFY       = LDAP_SYNC_MODIFY,
0854     LDAP_SYNC_CAPI_DELETE       = LDAP_SYNC_DELETE,
0855 
0856     /* these are passed to ls_intermediate() */
0857     LDAP_SYNC_CAPI_PRESENTS     = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_PRESENT ),
0858     LDAP_SYNC_CAPI_DELETES      = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_DELETE ),
0859 
0860     LDAP_SYNC_CAPI_PRESENTS_IDSET   = ( LDAP_SYNC_CAPI_PRESENTS | LDAP_SYNC_CAPI_IDSET_FLAG ),
0861     LDAP_SYNC_CAPI_DELETES_IDSET    = ( LDAP_SYNC_CAPI_DELETES | LDAP_SYNC_CAPI_IDSET_FLAG ),
0862 
0863     LDAP_SYNC_CAPI_DONE     = ( LDAP_SYNC_CAPI_DONE_FLAG | LDAP_SYNC_CAPI_PRESENTS )
0864 } ldap_sync_refresh_t;
0865 
0866 /*
0867  * Called when an entry is returned by ldap_result().
0868  * If phase is LDAP_SYNC_CAPI_ADD or LDAP_SYNC_CAPI_MODIFY,
0869  * the entry has been either added or modified, and thus
0870  * the complete view of the entry should be in the LDAPMessage.
0871  * If phase is LDAP_SYNC_CAPI_PRESENT or LDAP_SYNC_CAPI_DELETE,
0872  * only the DN should be in the LDAPMessage.
0873  */
0874 typedef int (*ldap_sync_search_entry_f) LDAP_P((
0875     ldap_sync_t         *ls,
0876     LDAPMessage         *msg,
0877     struct berval           *entryUUID,
0878     ldap_sync_refresh_t     phase ));
0879 
0880 /*
0881  * Called when a reference is returned; the client should know 
0882  * what to do with it.
0883  */
0884 typedef int (*ldap_sync_search_reference_f) LDAP_P((
0885     ldap_sync_t         *ls,
0886     LDAPMessage         *msg ));
0887 
0888 /*
0889  * Called when specific intermediate/final messages are returned.
0890  * If phase is LDAP_SYNC_CAPI_PRESENTS or LDAP_SYNC_CAPI_DELETES,
0891  * a "presents" or "deletes" phase begins.
0892  * If phase is LDAP_SYNC_CAPI_DONE, a special "presents" phase
0893  * with refreshDone set to "TRUE" has been returned, to indicate
0894  * that the refresh phase of a refreshAndPersist is complete.
0895  * In the above cases, syncUUIDs is NULL.
0896  *
0897  * If phase is LDAP_SYNC_CAPI_PRESENTS_IDSET or 
0898  * LDAP_SYNC_CAPI_DELETES_IDSET, syncUUIDs is an array of UUIDs
0899  * that are either present or have been deleted.
0900  */
0901 typedef int (*ldap_sync_intermediate_f) LDAP_P((
0902     ldap_sync_t         *ls,
0903     LDAPMessage         *msg,
0904     BerVarray           syncUUIDs,
0905     ldap_sync_refresh_t     phase ));
0906 
0907 /*
0908  * Called when a searchResultDone is returned.  In refreshAndPersist,
0909  * this can only occur if the search for any reason is being terminated
0910  * by the server.
0911  */
0912 typedef int (*ldap_sync_search_result_f) LDAP_P((
0913     ldap_sync_t         *ls,
0914     LDAPMessage         *msg,
0915     int             refreshDeletes ));
0916 
0917 /*
0918  * This structure contains all information about the persistent search;
0919  * the caller is responsible for connecting, setting version, binding, tls...
0920  */
0921 struct ldap_sync_t {
0922     /* conf search params */
0923     char                *ls_base;
0924     int             ls_scope;
0925     char                *ls_filter;
0926     char                **ls_attrs;
0927     int             ls_timelimit;
0928     int             ls_sizelimit;
0929 
0930     /* poll timeout */
0931     int             ls_timeout;
0932 
0933     /* helpers - add as appropriate */
0934     ldap_sync_search_entry_f    ls_search_entry;
0935     ldap_sync_search_reference_f    ls_search_reference;
0936     ldap_sync_intermediate_f    ls_intermediate;
0937     ldap_sync_search_result_f   ls_search_result;
0938 
0939     /* set by the caller as appropriate */
0940     void                *ls_private;
0941 
0942     /* conn stuff */
0943     LDAP                *ls_ld;
0944 
0945     /* --- the parameters below are private - do not modify --- */
0946 
0947     /* FIXME: make the structure opaque, and provide an interface
0948      * to modify the public values? */
0949 
0950     /* result stuff */
0951     int             ls_msgid;
0952 
0953     /* sync stuff */
0954     /* needed by refreshOnly */
0955     int             ls_reloadHint;
0956 
0957     /* opaque - need to pass between sessions, updated by the API */
0958     struct berval           ls_cookie;
0959 
0960     /* state variable - do not modify */
0961     ldap_sync_refresh_t     ls_refreshPhase;
0962 };
0963 
0964 /*
0965  * End of LDAP sync (RFC4533) API
0966  */
0967 
0968 /*
0969  * Connection callbacks...
0970  */
0971 struct ldap_conncb;
0972 struct sockaddr;
0973 
0974 /* Called after a connection is established */
0975 typedef int (ldap_conn_add_f) LDAP_P(( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, struct sockaddr *addr,
0976     struct ldap_conncb *ctx ));
0977 /* Called before a connection is closed */
0978 typedef void (ldap_conn_del_f) LDAP_P(( LDAP *ld, Sockbuf *sb, struct ldap_conncb *ctx ));
0979 
0980 /* Callbacks are pushed on a stack. Last one pushed is first one executed. The
0981  * delete callback is called with a NULL Sockbuf just before freeing the LDAP handle.
0982  */
0983 typedef struct ldap_conncb {
0984     ldap_conn_add_f *lc_add;
0985     ldap_conn_del_f *lc_del;
0986     void *lc_arg;
0987 } ldap_conncb;
0988 
0989 /*
0990  * The API draft spec says we should declare (or cause to be declared)
0991  * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
0992  */
0993 struct timeval;
0994 
0995 /*
0996  * in options.c:
0997  */
0998 LDAP_F( int )
0999 ldap_get_option LDAP_P((
1000     LDAP *ld,
1001     int option,
1002     void *outvalue));
1003 
1004 LDAP_F( int )
1005 ldap_set_option LDAP_P((
1006     LDAP *ld,
1007     int option,
1008     LDAP_CONST void *invalue));
1009 
1010 /* V3 REBIND Function Callback Prototype */
1011 typedef int (LDAP_REBIND_PROC) LDAP_P((
1012     LDAP *ld, LDAP_CONST char *url,
1013     ber_tag_t request, ber_int_t msgid,
1014     void *params ));
1015 
1016 LDAP_F( int )
1017 ldap_set_rebind_proc LDAP_P((
1018     LDAP *ld,
1019     LDAP_REBIND_PROC *rebind_proc,
1020     void *params ));
1021 
1022 /* V3 referral selection Function Callback Prototype */
1023 typedef int (LDAP_NEXTREF_PROC) LDAP_P((
1024     LDAP *ld, char ***refsp, int *cntp,
1025     void *params ));
1026 
1027 LDAP_F( int )
1028 ldap_set_nextref_proc LDAP_P((
1029     LDAP *ld,
1030     LDAP_NEXTREF_PROC *nextref_proc,
1031     void *params ));
1032 
1033 /* V3 URLLIST Function Callback Prototype */
1034 typedef int (LDAP_URLLIST_PROC) LDAP_P((
1035     LDAP *ld, 
1036     LDAPURLDesc **urllist,
1037     LDAPURLDesc **url,
1038     void *params ));
1039 
1040 LDAP_F( int )
1041 ldap_set_urllist_proc LDAP_P((
1042     LDAP *ld,
1043     LDAP_URLLIST_PROC *urllist_proc,
1044     void *params ));
1045 
1046 /*
1047  * in controls.c:
1048  */
1049 #if LDAP_DEPRECATED 
1050 LDAP_F( int )
1051 ldap_create_control LDAP_P((    /* deprecated, use ldap_control_create */
1052     LDAP_CONST char *requestOID,
1053     BerElement *ber,
1054     int iscritical,
1055     LDAPControl **ctrlp ));
1056 
1057 LDAP_F( LDAPControl * )
1058 ldap_find_control LDAP_P((  /* deprecated, use ldap_control_find */
1059     LDAP_CONST char *oid,
1060     LDAPControl **ctrls ));
1061 #endif
1062 
1063 LDAP_F( int )
1064 ldap_control_create LDAP_P((
1065     LDAP_CONST char *requestOID,
1066     int iscritical,
1067     struct berval *value,
1068     int dupval,
1069     LDAPControl **ctrlp ));
1070 
1071 LDAP_F( LDAPControl * )
1072 ldap_control_find LDAP_P((
1073     LDAP_CONST char *oid,
1074     LDAPControl **ctrls,
1075     LDAPControl ***nextctrlp ));
1076 
1077 LDAP_F( void )
1078 ldap_control_free LDAP_P((
1079     LDAPControl *ctrl ));
1080 
1081 LDAP_F( void )
1082 ldap_controls_free LDAP_P((
1083     LDAPControl **ctrls ));
1084 
1085 LDAP_F( LDAPControl ** )
1086 ldap_controls_dup LDAP_P((
1087     LDAPControl *LDAP_CONST *controls ));
1088 
1089 LDAP_F( LDAPControl * )
1090 ldap_control_dup LDAP_P((
1091     LDAP_CONST LDAPControl *c ));
1092 
1093 /*
1094  * in dnssrv.c:
1095  */
1096 LDAP_F( int )
1097 ldap_domain2dn LDAP_P((
1098     LDAP_CONST char* domain,
1099     char** dn ));
1100 
1101 LDAP_F( int )
1102 ldap_dn2domain LDAP_P((
1103     LDAP_CONST char* dn,
1104     char** domain ));
1105 
1106 LDAP_F( int )
1107 ldap_domain2hostlist LDAP_P((
1108     LDAP_CONST char *domain,
1109     char** hostlist ));
1110 
1111 /*
1112  * in extended.c:
1113  */
1114 LDAP_F( int )
1115 ldap_extended_operation LDAP_P((
1116     LDAP            *ld,
1117     LDAP_CONST char *reqoid,
1118     struct berval   *reqdata,
1119     LDAPControl     **serverctrls,
1120     LDAPControl     **clientctrls,
1121     int             *msgidp ));
1122 
1123 LDAP_F( int )
1124 ldap_extended_operation_s LDAP_P((
1125     LDAP            *ld,
1126     LDAP_CONST char *reqoid,
1127     struct berval   *reqdata,
1128     LDAPControl     **serverctrls,
1129     LDAPControl     **clientctrls,
1130     char            **retoidp,
1131     struct berval   **retdatap ));
1132 
1133 LDAP_F( int )
1134 ldap_parse_extended_result LDAP_P((
1135     LDAP            *ld,
1136     LDAPMessage     *res,
1137     char            **retoidp,
1138     struct berval   **retdatap,
1139     int             freeit ));
1140 
1141 LDAP_F( int )
1142 ldap_parse_intermediate LDAP_P((
1143     LDAP            *ld,
1144     LDAPMessage     *res,
1145     char            **retoidp,
1146     struct berval   **retdatap,
1147     LDAPControl     ***serverctrls,
1148     int             freeit ));
1149 
1150 
1151 /*
1152  * in abandon.c:
1153  */
1154 LDAP_F( int )
1155 ldap_abandon_ext LDAP_P((
1156     LDAP            *ld,
1157     int             msgid,
1158     LDAPControl     **serverctrls,
1159     LDAPControl     **clientctrls ));
1160 
1161 #if LDAP_DEPRECATED 
1162 LDAP_F( int )
1163 ldap_abandon LDAP_P((   /* deprecated, use ldap_abandon_ext */
1164     LDAP *ld,
1165     int msgid ));
1166 #endif
1167 
1168 /*
1169  * in add.c:
1170  */
1171 LDAP_F( int )
1172 ldap_add_ext LDAP_P((
1173     LDAP            *ld,
1174     LDAP_CONST char *dn,
1175     LDAPMod         **attrs,
1176     LDAPControl     **serverctrls,
1177     LDAPControl     **clientctrls,
1178     int             *msgidp ));
1179 
1180 LDAP_F( int )
1181 ldap_add_ext_s LDAP_P((
1182     LDAP            *ld,
1183     LDAP_CONST char *dn,
1184     LDAPMod         **attrs,
1185     LDAPControl     **serverctrls,
1186     LDAPControl     **clientctrls ));
1187 
1188 #if LDAP_DEPRECATED
1189 LDAP_F( int )
1190 ldap_add LDAP_P((   /* deprecated, use ldap_add_ext */
1191     LDAP *ld,
1192     LDAP_CONST char *dn,
1193     LDAPMod **attrs ));
1194 
1195 LDAP_F( int )
1196 ldap_add_s LDAP_P(( /* deprecated, use ldap_add_ext_s */
1197     LDAP *ld,
1198     LDAP_CONST char *dn,
1199     LDAPMod **attrs ));
1200 #endif
1201 
1202 
1203 /*
1204  * in sasl.c:
1205  */
1206 LDAP_F( int )
1207 ldap_sasl_bind LDAP_P((
1208     LDAP            *ld,
1209     LDAP_CONST char *dn,
1210     LDAP_CONST char *mechanism,
1211     struct berval   *cred,
1212     LDAPControl     **serverctrls,
1213     LDAPControl     **clientctrls,
1214     int             *msgidp ));
1215 
1216 /* Interaction flags (should be passed about in a control)
1217  *  Automatic (default): use defaults, prompt otherwise
1218  *  Interactive: prompt always
1219  *  Quiet: never prompt
1220  */
1221 #define LDAP_SASL_AUTOMATIC     0U
1222 #define LDAP_SASL_INTERACTIVE   1U
1223 #define LDAP_SASL_QUIET         2U
1224 
1225 /*
1226  * V3 SASL Interaction Function Callback Prototype
1227  *  when using Cyrus SASL, interact is pointer to sasl_interact_t
1228  *  should likely passed in a control (and provided controls)
1229  */
1230 typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P((
1231     LDAP *ld, unsigned flags, void* defaults, void *interact ));
1232 
1233 LDAP_F( int )
1234 ldap_sasl_interactive_bind LDAP_P((
1235     LDAP *ld,
1236     LDAP_CONST char *dn, /* usually NULL */
1237     LDAP_CONST char *saslMechanism,
1238     LDAPControl **serverControls,
1239     LDAPControl **clientControls,
1240 
1241     /* should be client controls */
1242     unsigned flags,
1243     LDAP_SASL_INTERACT_PROC *proc,
1244     void *defaults,
1245     
1246     /* as obtained from ldap_result() */
1247     LDAPMessage *result,
1248 
1249     /* returned during bind processing */
1250     const char **rmech,
1251     int *msgid ));
1252 
1253 LDAP_F( int )
1254 ldap_sasl_interactive_bind_s LDAP_P((
1255     LDAP *ld,
1256     LDAP_CONST char *dn, /* usually NULL */
1257     LDAP_CONST char *saslMechanism,
1258     LDAPControl **serverControls,
1259     LDAPControl **clientControls,
1260 
1261     /* should be client controls */
1262     unsigned flags,
1263     LDAP_SASL_INTERACT_PROC *proc,
1264     void *defaults ));
1265 
1266 LDAP_F( int )
1267 ldap_sasl_bind_s LDAP_P((
1268     LDAP            *ld,
1269     LDAP_CONST char *dn,
1270     LDAP_CONST char *mechanism,
1271     struct berval   *cred,
1272     LDAPControl     **serverctrls,
1273     LDAPControl     **clientctrls,
1274     struct berval   **servercredp ));
1275 
1276 LDAP_F( int )
1277 ldap_parse_sasl_bind_result LDAP_P((
1278     LDAP            *ld,
1279     LDAPMessage     *res,
1280     struct berval   **servercredp,
1281     int             freeit ));
1282 
1283 #if LDAP_DEPRECATED
1284 /*
1285  * in bind.c:
1286  *  (deprecated)
1287  */
1288 LDAP_F( int )
1289 ldap_bind LDAP_P((  /* deprecated, use ldap_sasl_bind */
1290     LDAP *ld,
1291     LDAP_CONST char *who,
1292     LDAP_CONST char *passwd,
1293     int authmethod ));
1294 
1295 LDAP_F( int )
1296 ldap_bind_s LDAP_P((    /* deprecated, use ldap_sasl_bind_s */
1297     LDAP *ld,
1298     LDAP_CONST char *who,
1299     LDAP_CONST char *cred,
1300     int authmethod ));
1301 
1302 /*
1303  * in sbind.c:
1304  */
1305 LDAP_F( int )
1306 ldap_simple_bind LDAP_P(( /* deprecated, use ldap_sasl_bind */
1307     LDAP *ld,
1308     LDAP_CONST char *who,
1309     LDAP_CONST char *passwd ));
1310 
1311 LDAP_F( int )
1312 ldap_simple_bind_s LDAP_P(( /* deprecated, use ldap_sasl_bind_s */
1313     LDAP *ld,
1314     LDAP_CONST char *who,
1315     LDAP_CONST char *passwd ));
1316 
1317 #endif
1318 
1319 
1320 /*
1321  * in compare.c:
1322  */
1323 LDAP_F( int )
1324 ldap_compare_ext LDAP_P((
1325     LDAP            *ld,
1326     LDAP_CONST char *dn,
1327     LDAP_CONST char *attr,
1328     struct berval   *bvalue,
1329     LDAPControl     **serverctrls,
1330     LDAPControl     **clientctrls,
1331     int             *msgidp ));
1332 
1333 LDAP_F( int )
1334 ldap_compare_ext_s LDAP_P((
1335     LDAP            *ld,
1336     LDAP_CONST char *dn,
1337     LDAP_CONST char *attr,
1338     struct berval   *bvalue,
1339     LDAPControl     **serverctrls,
1340     LDAPControl     **clientctrls ));
1341 
1342 #if LDAP_DEPRECATED
1343 LDAP_F( int )
1344 ldap_compare LDAP_P((   /* deprecated, use ldap_compare_ext */
1345     LDAP *ld,
1346     LDAP_CONST char *dn,
1347     LDAP_CONST char *attr,
1348     LDAP_CONST char *value ));
1349 
1350 LDAP_F( int )
1351 ldap_compare_s LDAP_P(( /* deprecated, use ldap_compare_ext_s */
1352     LDAP *ld,
1353     LDAP_CONST char *dn,
1354     LDAP_CONST char *attr,
1355     LDAP_CONST char *value ));
1356 #endif
1357 
1358 
1359 /*
1360  * in delete.c:
1361  */
1362 LDAP_F( int )
1363 ldap_delete_ext LDAP_P((
1364     LDAP            *ld,
1365     LDAP_CONST char *dn,
1366     LDAPControl     **serverctrls,
1367     LDAPControl     **clientctrls,
1368     int             *msgidp ));
1369 
1370 LDAP_F( int )
1371 ldap_delete_ext_s LDAP_P((
1372     LDAP            *ld,
1373     LDAP_CONST char *dn,
1374     LDAPControl     **serverctrls,
1375     LDAPControl     **clientctrls ));
1376 
1377 #if LDAP_DEPRECATED
1378 LDAP_F( int )
1379 ldap_delete LDAP_P((    /* deprecated, use ldap_delete_ext */
1380     LDAP *ld,
1381     LDAP_CONST char *dn ));
1382 
1383 LDAP_F( int )
1384 ldap_delete_s LDAP_P((  /* deprecated, use ldap_delete_ext_s */
1385     LDAP *ld,
1386     LDAP_CONST char *dn ));
1387 #endif
1388 
1389 
1390 /*
1391  * in error.c:
1392  */
1393 LDAP_F( int )
1394 ldap_parse_result LDAP_P((
1395     LDAP            *ld,
1396     LDAPMessage     *res,
1397     int             *errcodep,
1398     char            **matcheddnp,
1399     char            **diagmsgp,
1400     char            ***referralsp,
1401     LDAPControl     ***serverctrls,
1402     int             freeit ));
1403 
1404 LDAP_F( char * )
1405 ldap_err2string LDAP_P((
1406     int err ));
1407 
1408 #if LDAP_DEPRECATED
1409 LDAP_F( int )
1410 ldap_result2error LDAP_P((  /* deprecated, use ldap_parse_result */
1411     LDAP *ld,
1412     LDAPMessage *r,
1413     int freeit ));
1414 
1415 LDAP_F( void )
1416 ldap_perror LDAP_P((    /* deprecated, use ldap_err2string */
1417     LDAP *ld,
1418     LDAP_CONST char *s ));
1419 #endif
1420 
1421 
1422 /*
1423  * in modify.c:
1424  */
1425 LDAP_F( int )
1426 ldap_modify_ext LDAP_P((
1427     LDAP            *ld,
1428     LDAP_CONST char *dn,
1429     LDAPMod         **mods,
1430     LDAPControl     **serverctrls,
1431     LDAPControl     **clientctrls,
1432     int             *msgidp ));
1433 
1434 LDAP_F( int )
1435 ldap_modify_ext_s LDAP_P((
1436     LDAP            *ld,
1437     LDAP_CONST char *dn,
1438     LDAPMod         **mods,
1439     LDAPControl     **serverctrls,
1440     LDAPControl     **clientctrls ));
1441 
1442 #if LDAP_DEPRECATED
1443 LDAP_F( int )
1444 ldap_modify LDAP_P((    /* deprecated, use ldap_modify_ext */
1445     LDAP *ld,
1446     LDAP_CONST char *dn,
1447     LDAPMod **mods ));
1448 
1449 LDAP_F( int )
1450 ldap_modify_s LDAP_P((  /* deprecated, use ldap_modify_ext_s */
1451     LDAP *ld,
1452     LDAP_CONST char *dn,
1453     LDAPMod **mods ));
1454 #endif
1455 
1456 
1457 /*
1458  * in modrdn.c:
1459  */
1460 LDAP_F( int )
1461 ldap_rename LDAP_P((
1462     LDAP *ld,
1463     LDAP_CONST char *dn,
1464     LDAP_CONST char *newrdn,
1465     LDAP_CONST char *newSuperior,
1466     int deleteoldrdn,
1467     LDAPControl **sctrls,
1468     LDAPControl **cctrls,
1469     int *msgidp ));
1470 
1471 LDAP_F( int )
1472 ldap_rename_s LDAP_P((
1473     LDAP *ld,
1474     LDAP_CONST char *dn,
1475     LDAP_CONST char *newrdn,
1476     LDAP_CONST char *newSuperior,
1477     int deleteoldrdn,
1478     LDAPControl **sctrls,
1479     LDAPControl **cctrls ));
1480 
1481 #if LDAP_DEPRECATED
1482 LDAP_F( int )
1483 ldap_rename2 LDAP_P((   /* deprecated, use ldap_rename */
1484     LDAP *ld,
1485     LDAP_CONST char *dn,
1486     LDAP_CONST char *newrdn,
1487     LDAP_CONST char *newSuperior,
1488     int deleteoldrdn ));
1489 
1490 LDAP_F( int )
1491 ldap_rename2_s LDAP_P(( /* deprecated, use ldap_rename_s */
1492     LDAP *ld,
1493     LDAP_CONST char *dn,
1494     LDAP_CONST char *newrdn,
1495     LDAP_CONST char *newSuperior,
1496     int deleteoldrdn ));
1497 
1498 LDAP_F( int )
1499 ldap_modrdn LDAP_P((    /* deprecated, use ldap_rename */
1500     LDAP *ld,
1501     LDAP_CONST char *dn,
1502     LDAP_CONST char *newrdn ));
1503 
1504 LDAP_F( int )
1505 ldap_modrdn_s LDAP_P((  /* deprecated, use ldap_rename_s */
1506     LDAP *ld,
1507     LDAP_CONST char *dn,
1508     LDAP_CONST char *newrdn ));
1509 
1510 LDAP_F( int )
1511 ldap_modrdn2 LDAP_P((   /* deprecated, use ldap_rename */
1512     LDAP *ld,
1513     LDAP_CONST char *dn,
1514     LDAP_CONST char *newrdn,
1515     int deleteoldrdn ));
1516 
1517 LDAP_F( int )
1518 ldap_modrdn2_s LDAP_P(( /* deprecated, use ldap_rename_s */
1519     LDAP *ld,
1520     LDAP_CONST char *dn,
1521     LDAP_CONST char *newrdn,
1522     int deleteoldrdn));
1523 #endif
1524 
1525 
1526 /*
1527  * in open.c:
1528  */
1529 #if LDAP_DEPRECATED
1530 LDAP_F( LDAP * )
1531 ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
1532     LDAP_CONST char *host,
1533     int port ));
1534 
1535 LDAP_F( LDAP * )
1536 ldap_open LDAP_P((  /* deprecated, use ldap_create or ldap_initialize */
1537     LDAP_CONST char *host,
1538     int port ));
1539 #endif
1540 
1541 LDAP_F( int )
1542 ldap_create LDAP_P((
1543     LDAP **ldp ));
1544 
1545 LDAP_F( int )
1546 ldap_initialize LDAP_P((
1547     LDAP **ldp,
1548     LDAP_CONST char *url ));
1549 
1550 LDAP_F( LDAP * )
1551 ldap_dup LDAP_P((
1552     LDAP *old ));
1553 
1554 LDAP_F( int )
1555 ldap_connect( LDAP *ld );
1556 
1557 /*
1558  * in tls.c
1559  */
1560 
1561 LDAP_F( int )
1562 ldap_tls_inplace LDAP_P((
1563     LDAP *ld ));
1564 
1565 LDAP_F( int )
1566 ldap_start_tls LDAP_P((
1567     LDAP *ld,
1568     LDAPControl **serverctrls,
1569     LDAPControl **clientctrls,
1570     int *msgidp ));
1571 
1572 LDAP_F( int )
1573 ldap_install_tls LDAP_P((
1574     LDAP *ld ));
1575 
1576 LDAP_F( int )
1577 ldap_start_tls_s LDAP_P((
1578     LDAP *ld,
1579     LDAPControl **serverctrls,
1580     LDAPControl **clientctrls ));
1581 
1582 /*
1583  * in messages.c:
1584  */
1585 LDAP_F( LDAPMessage * )
1586 ldap_first_message LDAP_P((
1587     LDAP *ld,
1588     LDAPMessage *chain ));
1589 
1590 LDAP_F( LDAPMessage * )
1591 ldap_next_message LDAP_P((
1592     LDAP *ld,
1593     LDAPMessage *msg ));
1594 
1595 LDAP_F( int )
1596 ldap_count_messages LDAP_P((
1597     LDAP *ld,
1598     LDAPMessage *chain ));
1599 
1600 /*
1601  * in references.c:
1602  */
1603 LDAP_F( LDAPMessage * )
1604 ldap_first_reference LDAP_P((
1605     LDAP *ld,
1606     LDAPMessage *chain ));
1607 
1608 LDAP_F( LDAPMessage * )
1609 ldap_next_reference LDAP_P((
1610     LDAP *ld,
1611     LDAPMessage *ref ));
1612 
1613 LDAP_F( int )
1614 ldap_count_references LDAP_P((
1615     LDAP *ld,
1616     LDAPMessage *chain ));
1617 
1618 LDAP_F( int )
1619 ldap_parse_reference LDAP_P((
1620     LDAP            *ld,
1621     LDAPMessage     *ref,
1622     char            ***referralsp,
1623     LDAPControl     ***serverctrls,
1624     int             freeit));
1625 
1626 
1627 /*
1628  * in getentry.c:
1629  */
1630 LDAP_F( LDAPMessage * )
1631 ldap_first_entry LDAP_P((
1632     LDAP *ld,
1633     LDAPMessage *chain ));
1634 
1635 LDAP_F( LDAPMessage * )
1636 ldap_next_entry LDAP_P((
1637     LDAP *ld,
1638     LDAPMessage *entry ));
1639 
1640 LDAP_F( int )
1641 ldap_count_entries LDAP_P((
1642     LDAP *ld,
1643     LDAPMessage *chain ));
1644 
1645 LDAP_F( int )
1646 ldap_get_entry_controls LDAP_P((
1647     LDAP            *ld,
1648     LDAPMessage     *entry,
1649     LDAPControl     ***serverctrls));
1650 
1651 
1652 /*
1653  * in addentry.c
1654  */
1655 LDAP_F( LDAPMessage * )
1656 ldap_delete_result_entry LDAP_P((
1657     LDAPMessage **list,
1658     LDAPMessage *e ));
1659 
1660 LDAP_F( void )
1661 ldap_add_result_entry LDAP_P((
1662     LDAPMessage **list,
1663     LDAPMessage *e ));
1664 
1665 
1666 /*
1667  * in getdn.c
1668  */
1669 LDAP_F( char * )
1670 ldap_get_dn LDAP_P((
1671     LDAP *ld,
1672     LDAPMessage *entry ));
1673 
1674 typedef struct ldap_ava {
1675     struct berval la_attr;
1676     struct berval la_value;
1677     unsigned la_flags;
1678 #define LDAP_AVA_NULL               0x0000U
1679 #define LDAP_AVA_STRING             0x0001U
1680 #define LDAP_AVA_BINARY             0x0002U
1681 #define LDAP_AVA_NONPRINTABLE       0x0004U
1682 #define LDAP_AVA_FREE_ATTR          0x0010U
1683 #define LDAP_AVA_FREE_VALUE         0x0020U
1684 
1685     void *la_private;
1686 } LDAPAVA;
1687 
1688 typedef LDAPAVA** LDAPRDN;
1689 typedef LDAPRDN* LDAPDN;
1690 
1691 /* DN formats */
1692 #define LDAP_DN_FORMAT_LDAP         0x0000U
1693 #define LDAP_DN_FORMAT_LDAPV3       0x0010U
1694 #define LDAP_DN_FORMAT_LDAPV2       0x0020U
1695 #define LDAP_DN_FORMAT_DCE          0x0030U
1696 #define LDAP_DN_FORMAT_UFN          0x0040U /* dn2str only */
1697 #define LDAP_DN_FORMAT_AD_CANONICAL 0x0050U /* dn2str only */
1698 #define LDAP_DN_FORMAT_LBER         0x00F0U /* for testing only */
1699 #define LDAP_DN_FORMAT_MASK         0x00F0U
1700 
1701 /* DN flags */
1702 #define LDAP_DN_PRETTY              0x0100U
1703 #define LDAP_DN_SKIP                0x0200U
1704 #define LDAP_DN_P_NOLEADTRAILSPACES 0x1000U
1705 #define LDAP_DN_P_NOSPACEAFTERRDN   0x2000U
1706 #define LDAP_DN_PEDANTIC            0xF000U
1707 
1708 LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN rdn ));
1709 LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN dn ));
1710 
1711 LDAP_F( int )
1712 ldap_bv2dn LDAP_P(( 
1713     struct berval *bv, 
1714     LDAPDN *dn, 
1715     unsigned flags ));
1716 
1717 LDAP_F( int )
1718 ldap_str2dn LDAP_P((
1719     LDAP_CONST char *str,
1720     LDAPDN *dn,
1721     unsigned flags ));
1722 
1723 LDAP_F( int )
1724 ldap_dn2bv LDAP_P((
1725     LDAPDN dn,
1726     struct berval *bv,
1727     unsigned flags ));
1728 
1729 LDAP_F( int )
1730 ldap_dn2str LDAP_P((
1731     LDAPDN dn,
1732     char **str,
1733     unsigned flags ));
1734 
1735 LDAP_F( int )
1736 ldap_bv2rdn LDAP_P((
1737     struct berval *bv,
1738     LDAPRDN *rdn,
1739     char **next,
1740     unsigned flags ));
1741 
1742 LDAP_F( int )
1743 ldap_str2rdn LDAP_P((
1744     LDAP_CONST char *str,
1745     LDAPRDN *rdn,
1746     char **next,
1747     unsigned flags ));
1748 
1749 LDAP_F( int )
1750 ldap_rdn2bv LDAP_P((
1751     LDAPRDN rdn,
1752     struct berval *bv,
1753     unsigned flags ));
1754 
1755 LDAP_F( int )
1756 ldap_rdn2str LDAP_P((
1757     LDAPRDN rdn,
1758     char **str,
1759     unsigned flags ));
1760 
1761 LDAP_F( int )
1762 ldap_dn_normalize LDAP_P((
1763     LDAP_CONST char *in, unsigned iflags,
1764     char **out, unsigned oflags ));
1765 
1766 LDAP_F( char * )
1767 ldap_dn2ufn LDAP_P(( /* deprecated, use ldap_str2dn/dn2str */
1768     LDAP_CONST char *dn ));
1769 
1770 LDAP_F( char ** )
1771 ldap_explode_dn LDAP_P(( /* deprecated, ldap_str2dn */
1772     LDAP_CONST char *dn,
1773     int notypes ));
1774 
1775 LDAP_F( char ** )
1776 ldap_explode_rdn LDAP_P(( /* deprecated, ldap_str2rdn */
1777     LDAP_CONST char *rdn,
1778     int notypes ));
1779 
1780 typedef int LDAPDN_rewrite_func
1781     LDAP_P(( LDAPDN dn, unsigned flags, void *ctx ));
1782 
1783 LDAP_F( int )
1784 ldap_X509dn2bv LDAP_P(( void *x509_name, struct berval *dn,
1785     LDAPDN_rewrite_func *func, unsigned flags ));
1786 
1787 LDAP_F( char * )
1788 ldap_dn2dcedn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1789     LDAP_CONST char *dn ));
1790 
1791 LDAP_F( char * )
1792 ldap_dcedn2dn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1793     LDAP_CONST char *dce ));
1794 
1795 LDAP_F( char * )
1796 ldap_dn2ad_canonical LDAP_P(( /* deprecated, ldap_str2dn/dn2str */
1797     LDAP_CONST char *dn ));
1798 
1799 LDAP_F( int )
1800 ldap_get_dn_ber LDAP_P((
1801     LDAP *ld, LDAPMessage *e, BerElement **berout, struct berval *dn ));
1802 
1803 LDAP_F( int )
1804 ldap_get_attribute_ber LDAP_P((
1805     LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr,
1806     struct berval **vals ));
1807 
1808 /*
1809  * in getattr.c
1810  */
1811 LDAP_F( char * )
1812 ldap_first_attribute LDAP_P((
1813     LDAP *ld,
1814     LDAPMessage *entry,
1815     BerElement **ber ));
1816 
1817 LDAP_F( char * )
1818 ldap_next_attribute LDAP_P((
1819     LDAP *ld,
1820     LDAPMessage *entry,
1821     BerElement *ber ));
1822 
1823 
1824 /*
1825  * in getvalues.c
1826  */
1827 LDAP_F( struct berval ** )
1828 ldap_get_values_len LDAP_P((
1829     LDAP *ld,
1830     LDAPMessage *entry,
1831     LDAP_CONST char *target ));
1832 
1833 LDAP_F( int )
1834 ldap_count_values_len LDAP_P((
1835     struct berval **vals ));
1836 
1837 LDAP_F( void )
1838 ldap_value_free_len LDAP_P((
1839     struct berval **vals ));
1840 
1841 #if LDAP_DEPRECATED
1842 LDAP_F( char ** )
1843 ldap_get_values LDAP_P((    /* deprecated, use ldap_get_values_len */
1844     LDAP *ld,
1845     LDAPMessage *entry,
1846     LDAP_CONST char *target ));
1847 
1848 LDAP_F( int )
1849 ldap_count_values LDAP_P((  /* deprecated, use ldap_count_values_len */
1850     char **vals ));
1851 
1852 LDAP_F( void )
1853 ldap_value_free LDAP_P((    /* deprecated, use ldap_value_free_len */
1854     char **vals ));
1855 #endif
1856 
1857 /*
1858  * in result.c:
1859  */
1860 LDAP_F( int )
1861 ldap_result LDAP_P((
1862     LDAP *ld,
1863     int msgid,
1864     int all,
1865     struct timeval *timeout,
1866     LDAPMessage **result ));
1867 
1868 LDAP_F( int )
1869 ldap_msgtype LDAP_P((
1870     LDAPMessage *lm ));
1871 
1872 LDAP_F( int )
1873 ldap_msgid   LDAP_P((
1874     LDAPMessage *lm ));
1875 
1876 LDAP_F( int )
1877 ldap_msgfree LDAP_P((
1878     LDAPMessage *lm ));
1879 
1880 LDAP_F( int )
1881 ldap_msgdelete LDAP_P((
1882     LDAP *ld,
1883     int msgid ));
1884 
1885 
1886 /*
1887  * in search.c:
1888  */
1889 LDAP_F( int )
1890 ldap_bv2escaped_filter_value LDAP_P(( 
1891     struct berval *in, 
1892     struct berval *out ));
1893 
1894 LDAP_F( int )
1895 ldap_search_ext LDAP_P((
1896     LDAP            *ld,
1897     LDAP_CONST char *base,
1898     int             scope,
1899     LDAP_CONST char *filter,
1900     char            **attrs,
1901     int             attrsonly,
1902     LDAPControl     **serverctrls,
1903     LDAPControl     **clientctrls,
1904     struct timeval  *timeout,
1905     int             sizelimit,
1906     int             *msgidp ));
1907 
1908 LDAP_F( int )
1909 ldap_search_ext_s LDAP_P((
1910     LDAP            *ld,
1911     LDAP_CONST char *base,
1912     int             scope,
1913     LDAP_CONST char *filter,
1914     char            **attrs,
1915     int             attrsonly,
1916     LDAPControl     **serverctrls,
1917     LDAPControl     **clientctrls,
1918     struct timeval  *timeout,
1919     int             sizelimit,
1920     LDAPMessage     **res ));
1921 
1922 #if LDAP_DEPRECATED
1923 LDAP_F( int )
1924 ldap_search LDAP_P((    /* deprecated, use ldap_search_ext */
1925     LDAP *ld,
1926     LDAP_CONST char *base,
1927     int scope,
1928     LDAP_CONST char *filter,
1929     char **attrs,
1930     int attrsonly ));
1931 
1932 LDAP_F( int )
1933 ldap_search_s LDAP_P((  /* deprecated, use ldap_search_ext_s */
1934     LDAP *ld,
1935     LDAP_CONST char *base,
1936     int scope,
1937     LDAP_CONST char *filter,
1938     char **attrs,
1939     int attrsonly,
1940     LDAPMessage **res ));
1941 
1942 LDAP_F( int )
1943 ldap_search_st LDAP_P(( /* deprecated, use ldap_search_ext_s */
1944     LDAP *ld,
1945     LDAP_CONST char *base,
1946     int scope,
1947     LDAP_CONST char *filter,
1948     char **attrs,
1949     int attrsonly,
1950     struct timeval *timeout,
1951     LDAPMessage **res ));
1952 #endif
1953 
1954 /*
1955  * in unbind.c
1956  */
1957 LDAP_F( int )
1958 ldap_unbind_ext LDAP_P((
1959     LDAP            *ld,
1960     LDAPControl     **serverctrls,
1961     LDAPControl     **clientctrls));
1962 
1963 LDAP_F( int )
1964 ldap_unbind_ext_s LDAP_P((
1965     LDAP            *ld,
1966     LDAPControl     **serverctrls,
1967     LDAPControl     **clientctrls));
1968 
1969 LDAP_F( int )
1970 ldap_destroy LDAP_P((
1971     LDAP            *ld));
1972 
1973 #if LDAP_DEPRECATED
1974 LDAP_F( int )
1975 ldap_unbind LDAP_P(( /* deprecated, use ldap_unbind_ext */
1976     LDAP *ld ));
1977 
1978 LDAP_F( int )
1979 ldap_unbind_s LDAP_P(( /* deprecated, use ldap_unbind_ext_s */
1980     LDAP *ld ));
1981 #endif
1982 
1983 /*
1984  * in filter.c
1985  */
1986 LDAP_F( int )
1987 ldap_put_vrFilter LDAP_P((
1988     BerElement *ber,
1989     const char *vrf ));
1990 
1991 /*
1992  * in free.c
1993  */
1994 
1995 LDAP_F( void * )
1996 ldap_memalloc LDAP_P((
1997     ber_len_t s ));
1998 
1999 LDAP_F( void * )
2000 ldap_memrealloc LDAP_P((
2001     void* p,
2002     ber_len_t s ));
2003 
2004 LDAP_F( void * )
2005 ldap_memcalloc LDAP_P((
2006     ber_len_t n,
2007     ber_len_t s ));
2008 
2009 LDAP_F( void )
2010 ldap_memfree LDAP_P((
2011     void* p ));
2012 
2013 LDAP_F( void )
2014 ldap_memvfree LDAP_P((
2015     void** v ));
2016 
2017 LDAP_F( char * )
2018 ldap_strdup LDAP_P((
2019     LDAP_CONST char * ));
2020 
2021 LDAP_F( void )
2022 ldap_mods_free LDAP_P((
2023     LDAPMod **mods,
2024     int freemods ));
2025 
2026 
2027 #if LDAP_DEPRECATED
2028 /*
2029  * in sort.c (deprecated, use custom code instead)
2030  */
2031 typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( /* deprecated */
2032     LDAP_CONST char *left,
2033     LDAP_CONST char *right ));
2034 
2035 typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P(( /* deprecated */
2036     LDAP_CONST void *left,
2037     LDAP_CONST void *right ));
2038 
2039 LDAP_F( int )   /* deprecated */
2040 ldap_sort_entries LDAP_P(( LDAP *ld,
2041     LDAPMessage **chain,
2042     LDAP_CONST char *attr,
2043     LDAP_SORT_AD_CMP_PROC *cmp ));
2044 
2045 LDAP_F( int )   /* deprecated */
2046 ldap_sort_values LDAP_P((
2047     LDAP *ld,
2048     char **vals,
2049     LDAP_SORT_AV_CMP_PROC *cmp ));
2050 
2051 LDAP_F( int ) /* deprecated */
2052 ldap_sort_strcasecmp LDAP_P((
2053     LDAP_CONST void *a,
2054     LDAP_CONST void *b ));
2055 #endif
2056 
2057 /*
2058  * in url.c
2059  */
2060 LDAP_F( int )
2061 ldap_is_ldap_url LDAP_P((
2062     LDAP_CONST char *url ));
2063 
2064 LDAP_F( int )
2065 ldap_is_ldaps_url LDAP_P((
2066     LDAP_CONST char *url ));
2067 
2068 LDAP_F( int )
2069 ldap_is_ldapi_url LDAP_P((
2070     LDAP_CONST char *url ));
2071 
2072 #ifdef LDAP_CONNECTIONLESS
2073 LDAP_F( int )
2074 ldap_is_ldapc_url LDAP_P((
2075     LDAP_CONST char *url ));
2076 #endif
2077 
2078 LDAP_F( int )
2079 ldap_url_parse LDAP_P((
2080     LDAP_CONST char *url,
2081     LDAPURLDesc **ludpp ));
2082 
2083 LDAP_F( char * )
2084 ldap_url_desc2str LDAP_P((
2085     LDAPURLDesc *ludp ));
2086 
2087 LDAP_F( void )
2088 ldap_free_urldesc LDAP_P((
2089     LDAPURLDesc *ludp ));
2090 
2091 
2092 /*
2093  * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt>
2094  *  in cancel.c
2095  */
2096 #define LDAP_API_FEATURE_CANCEL 1000
2097 
2098 LDAP_F( int )
2099 ldap_cancel LDAP_P(( LDAP *ld,
2100     int cancelid,
2101     LDAPControl     **sctrls,
2102     LDAPControl     **cctrls,
2103     int             *msgidp ));
2104 
2105 LDAP_F( int )
2106 ldap_cancel_s LDAP_P(( LDAP *ld,
2107     int cancelid,
2108     LDAPControl **sctrl,
2109     LDAPControl **cctrl ));
2110 
2111 /*
2112  * LDAP Turn Extended Operation <draft-zeilenga-ldap-turn-xx.txt>
2113  *  in turn.c
2114  */
2115 #define LDAP_API_FEATURE_TURN 1000
2116 
2117 LDAP_F( int )
2118 ldap_turn LDAP_P(( LDAP *ld,
2119     int mutual,
2120     LDAP_CONST char* identifier,
2121     LDAPControl     **sctrls,
2122     LDAPControl     **cctrls,
2123     int             *msgidp ));
2124 
2125 LDAP_F( int )
2126 ldap_turn_s LDAP_P(( LDAP *ld,
2127     int mutual,
2128     LDAP_CONST char* identifier,
2129     LDAPControl **sctrl,
2130     LDAPControl **cctrl ));
2131 
2132 /*
2133  * LDAP Paged Results
2134  *  in pagectrl.c
2135  */
2136 #define LDAP_API_FEATURE_PAGED_RESULTS 2000
2137 
2138 LDAP_F( int )
2139 ldap_create_page_control_value LDAP_P((
2140     LDAP *ld,
2141     ber_int_t pagesize,
2142     struct berval *cookie,
2143     struct berval *value ));
2144 
2145 LDAP_F( int )
2146 ldap_create_page_control LDAP_P((
2147     LDAP *ld,
2148     ber_int_t pagesize,
2149     struct berval *cookie,
2150     int iscritical,
2151     LDAPControl **ctrlp ));
2152 
2153 #if LDAP_DEPRECATED
2154 LDAP_F( int )
2155 ldap_parse_page_control LDAP_P((
2156     /* deprecated, use ldap_parse_pageresponse_control */
2157     LDAP *ld,
2158     LDAPControl **ctrls,
2159     ber_int_t *count,
2160     struct berval **cookie ));
2161 #endif
2162 
2163 LDAP_F( int )
2164 ldap_parse_pageresponse_control LDAP_P((
2165     LDAP *ld,
2166     LDAPControl *ctrl,
2167     ber_int_t *count,
2168     struct berval *cookie ));
2169 
2170 /*
2171  * LDAP Server Side Sort
2172  *  in sortctrl.c
2173  */
2174 #define LDAP_API_FEATURE_SERVER_SIDE_SORT 2000
2175 
2176 /* structure for a sort-key */
2177 typedef struct ldapsortkey {
2178     char *attributeType;
2179     char *orderingRule;
2180     int reverseOrder;
2181 } LDAPSortKey;
2182 
2183 LDAP_F( int )
2184 ldap_create_sort_keylist LDAP_P((
2185     LDAPSortKey ***sortKeyList,
2186     char *keyString ));
2187 
2188 LDAP_F( void )
2189 ldap_free_sort_keylist LDAP_P((
2190     LDAPSortKey **sortkeylist ));
2191 
2192 LDAP_F( int )
2193 ldap_create_sort_control_value LDAP_P((
2194     LDAP *ld,
2195     LDAPSortKey **keyList,
2196     struct berval *value ));
2197 
2198 LDAP_F( int )
2199 ldap_create_sort_control LDAP_P((
2200     LDAP *ld,
2201     LDAPSortKey **keyList,
2202     int iscritical,
2203     LDAPControl **ctrlp ));
2204 
2205 LDAP_F( int )
2206 ldap_parse_sortresponse_control LDAP_P((
2207     LDAP *ld,
2208     LDAPControl *ctrl,
2209     ber_int_t *result,
2210     char **attribute ));
2211 
2212 /*
2213  * LDAP Virtual List View
2214  *  in vlvctrl.c
2215  */
2216 #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 2000
2217 
2218 /* structure for virtual list */
2219 typedef struct ldapvlvinfo {
2220     ber_int_t ldvlv_version;
2221     ber_int_t ldvlv_before_count;
2222     ber_int_t ldvlv_after_count;
2223     ber_int_t ldvlv_offset;
2224     ber_int_t ldvlv_count;
2225     struct berval * ldvlv_attrvalue;
2226     struct berval * ldvlv_context;
2227     void *          ldvlv_extradata;
2228 } LDAPVLVInfo;
2229 
2230 LDAP_F( int )
2231 ldap_create_vlv_control_value LDAP_P((
2232     LDAP *ld,
2233     LDAPVLVInfo *ldvlistp,
2234     struct berval *value));
2235 
2236 LDAP_F( int )
2237 ldap_create_vlv_control LDAP_P((
2238     LDAP *ld,
2239     LDAPVLVInfo *ldvlistp,
2240     LDAPControl **ctrlp ));
2241 
2242 LDAP_F( int )
2243 ldap_parse_vlvresponse_control LDAP_P((
2244     LDAP          *ld,
2245     LDAPControl   *ctrls,
2246     ber_int_t *target_posp,
2247     ber_int_t *list_countp,
2248     struct berval **contextp,
2249     int           *errcodep ));
2250 
2251 /*
2252  * LDAP Verify Credentials
2253  */
2254 #define LDAP_API_FEATURE_VERIFY_CREDENTIALS 1000
2255 
2256 LDAP_F( int )
2257 ldap_verify_credentials LDAP_P((
2258     LDAP        *ld,
2259     struct berval   *cookie,
2260     LDAP_CONST char *dn,
2261     LDAP_CONST char *mechanism,
2262     struct berval   *cred,
2263     LDAPControl **ctrls,
2264     LDAPControl **serverctrls,
2265     LDAPControl **clientctrls,
2266     int     *msgidp ));
2267 
2268 LDAP_F( int )
2269 ldap_verify_credentials_s LDAP_P((
2270     LDAP        *ld,
2271     struct berval   *cookie,
2272     LDAP_CONST char *dn,
2273     LDAP_CONST char *mechanism,
2274     struct berval   *cred,
2275     LDAPControl **vcictrls,
2276     LDAPControl **serverctrls,
2277     LDAPControl **clientctrls,
2278     int             *code,
2279     char            **diagmsgp,
2280     struct berval   **scookie,
2281     struct berval   **servercredp,
2282     LDAPControl ***vcoctrls));
2283     
2284 
2285 LDAP_F( int )
2286 ldap_parse_verify_credentials LDAP_P((
2287     LDAP        *ld,
2288     LDAPMessage *res,
2289     int         *code,
2290     char            **diagmsgp,
2291     struct berval   **cookie,
2292     struct berval   **servercredp,
2293     LDAPControl ***vcctrls));
2294 
2295 /* not yet implemented */
2296 /* #define LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE 1000 */
2297 #ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE
2298 LDAP_F( int )
2299 ldap_verify_credentials_interactive LDAP_P((
2300     LDAP *ld,
2301     LDAP_CONST char *dn, /* usually NULL */
2302     LDAP_CONST char *saslMechanism,
2303     LDAPControl **vcControls,
2304     LDAPControl **serverControls,
2305     LDAPControl **clientControls,
2306 
2307     /* should be client controls */
2308     unsigned flags,
2309     LDAP_SASL_INTERACT_PROC *proc,
2310     void *defaults,
2311     void *context,
2312     
2313     /* as obtained from ldap_result() */
2314     LDAPMessage *result,
2315 
2316     /* returned during bind processing */
2317     const char **rmech,
2318     int *msgid ));
2319 #endif
2320 
2321 /*
2322  * LDAP Who Am I?
2323  *  in whoami.c
2324  */
2325 #define LDAP_API_FEATURE_WHOAMI 1000
2326 
2327 LDAP_F( int )
2328 ldap_parse_whoami LDAP_P((
2329     LDAP *ld,
2330     LDAPMessage *res,
2331     struct berval **authzid ));
2332 
2333 LDAP_F( int )
2334 ldap_whoami LDAP_P(( LDAP *ld,
2335     LDAPControl     **sctrls,
2336     LDAPControl     **cctrls,
2337     int             *msgidp ));
2338 
2339 LDAP_F( int )
2340 ldap_whoami_s LDAP_P((
2341     LDAP *ld,
2342     struct berval **authzid,
2343     LDAPControl **sctrls,
2344     LDAPControl **cctrls ));
2345 
2346 /*
2347  * LDAP Password Modify
2348  *  in passwd.c
2349  */
2350 #define LDAP_API_FEATURE_PASSWD_MODIFY 1000
2351 
2352 LDAP_F( int )
2353 ldap_parse_passwd LDAP_P((
2354     LDAP *ld,
2355     LDAPMessage *res,
2356     struct berval *newpasswd ));
2357 
2358 LDAP_F( int )
2359 ldap_passwd LDAP_P(( LDAP *ld,
2360     struct berval   *user,
2361     struct berval   *oldpw,
2362     struct berval   *newpw,
2363     LDAPControl     **sctrls,
2364     LDAPControl     **cctrls,
2365     int             *msgidp ));
2366 
2367 LDAP_F( int )
2368 ldap_passwd_s LDAP_P((
2369     LDAP *ld,
2370     struct berval   *user,
2371     struct berval   *oldpw,
2372     struct berval   *newpw,
2373     struct berval *newpasswd,
2374     LDAPControl **sctrls,
2375     LDAPControl **cctrls ));
2376 
2377 #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST
2378 /*
2379  * LDAP Password Policy controls
2380  *  in ppolicy.c
2381  */
2382 #define LDAP_API_FEATURE_PASSWORD_POLICY 1000
2383 
2384 typedef enum passpolicyerror_enum {
2385        PP_passwordExpired = 0,
2386        PP_accountLocked = 1,
2387        PP_changeAfterReset = 2,
2388        PP_passwordModNotAllowed = 3,
2389        PP_mustSupplyOldPassword = 4,
2390        PP_insufficientPasswordQuality = 5,
2391        PP_passwordTooShort = 6,
2392        PP_passwordTooYoung = 7,
2393        PP_passwordInHistory = 8,
2394        PP_passwordTooLong = 9,
2395        PP_noError = 65535
2396 } LDAPPasswordPolicyError;
2397 
2398 LDAP_F( int )
2399 ldap_create_passwordpolicy_control LDAP_P((
2400         LDAP *ld,
2401         LDAPControl **ctrlp ));
2402 
2403 LDAP_F( int )
2404 ldap_parse_passwordpolicy_control LDAP_P((
2405         LDAP *ld,
2406         LDAPControl *ctrl,
2407         ber_int_t *expirep,
2408         ber_int_t *gracep,
2409         LDAPPasswordPolicyError *errorp ));
2410 
2411 LDAP_F( const char * )
2412 ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError ));
2413 #endif /* LDAP_CONTROL_PASSWORDPOLICYREQUEST */
2414 
2415 LDAP_F( int )
2416 ldap_parse_password_expiring_control LDAP_P((
2417     LDAP           *ld,
2418     LDAPControl    *ctrl,
2419     long           *secondsp ));
2420 
2421 /*
2422  * LDAP Dynamic Directory Services Refresh -- RFC 2589
2423  *  in dds.c
2424  */
2425 #define LDAP_API_FEATURE_REFRESH 1000
2426 
2427 LDAP_F( int )
2428 ldap_parse_refresh LDAP_P((
2429     LDAP *ld,
2430     LDAPMessage *res,
2431     ber_int_t *newttl ));
2432 
2433 LDAP_F( int )
2434 ldap_refresh LDAP_P(( LDAP *ld,
2435     struct berval   *dn,
2436     ber_int_t ttl,
2437     LDAPControl     **sctrls,
2438     LDAPControl     **cctrls,
2439     int             *msgidp ));
2440 
2441 LDAP_F( int )
2442 ldap_refresh_s LDAP_P((
2443     LDAP *ld,
2444     struct berval   *dn,
2445     ber_int_t ttl,
2446     ber_int_t *newttl,
2447     LDAPControl **sctrls,
2448     LDAPControl **cctrls ));
2449 
2450 /*
2451  * LDAP Transactions
2452  */
2453 LDAP_F( int )
2454 ldap_txn_start LDAP_P(( LDAP *ld,
2455     LDAPControl     **sctrls,
2456     LDAPControl     **cctrls,
2457     int             *msgidp ));
2458 
2459 LDAP_F( int )
2460 ldap_txn_start_s LDAP_P(( LDAP *ld,
2461     LDAPControl **sctrl,
2462     LDAPControl **cctrl,
2463     struct berval **rettxnid ));
2464 
2465 LDAP_F( int )
2466 ldap_txn_end LDAP_P(( LDAP *ld,
2467     int commit,
2468     struct berval   *txnid,
2469     LDAPControl     **sctrls,
2470     LDAPControl     **cctrls,
2471     int             *msgidp ));
2472 
2473 LDAP_F( int )
2474 ldap_txn_end_s LDAP_P(( LDAP *ld,
2475     int commit,
2476     struct berval *txnid,
2477     LDAPControl **sctrl,
2478     LDAPControl **cctrl,
2479     int *retidp ));
2480 
2481 /*
2482  * in ldap_sync.c
2483  */
2484 
2485 /*
2486  * initialize the persistent search structure
2487  */
2488 LDAP_F( ldap_sync_t * )
2489 ldap_sync_initialize LDAP_P((
2490     ldap_sync_t *ls ));
2491 
2492 /*
2493  * destroy the persistent search structure
2494  */
2495 LDAP_F( void )
2496 ldap_sync_destroy LDAP_P((
2497     ldap_sync_t *ls,
2498     int     freeit ));
2499 
2500 /*
2501  * initialize a refreshOnly sync
2502  */
2503 LDAP_F( int )
2504 ldap_sync_init LDAP_P((
2505     ldap_sync_t *ls,
2506     int     mode ));
2507 
2508 /*
2509  * initialize a refreshOnly sync
2510  */
2511 LDAP_F( int )
2512 ldap_sync_init_refresh_only LDAP_P((
2513     ldap_sync_t *ls ));
2514 
2515 /*
2516  * initialize a refreshAndPersist sync
2517  */
2518 LDAP_F( int )
2519 ldap_sync_init_refresh_and_persist LDAP_P((
2520     ldap_sync_t *ls ));
2521 
2522 /*
2523  * poll for new responses
2524  */
2525 LDAP_F( int )
2526 ldap_sync_poll LDAP_P((
2527     ldap_sync_t *ls ));
2528 
2529 #ifdef LDAP_CONTROL_X_SESSION_TRACKING
2530 
2531 /*
2532  * in stctrl.c
2533  */
2534 LDAP_F( int )
2535 ldap_create_session_tracking_value LDAP_P((
2536     LDAP        *ld,
2537     char        *sessionSourceIp,
2538     char        *sessionSourceName,
2539     char        *formatOID,
2540     struct berval   *sessionTrackingIdentifier,
2541     struct berval   *value ));
2542 
2543 LDAP_F( int )
2544 ldap_create_session_tracking_control LDAP_P((
2545     LDAP        *ld,
2546     char        *sessionSourceIp,
2547     char        *sessionSourceName,
2548     char        *formatOID,
2549     struct berval   *sessionTrackingIdentifier,
2550     LDAPControl **ctrlp ));
2551 
2552 LDAP_F( int )
2553 ldap_parse_session_tracking_control LDAP_P((
2554     LDAP *ld,
2555     LDAPControl *ctrl,
2556     struct berval *ip,
2557     struct berval *name,
2558     struct berval *oid,
2559     struct berval *id ));
2560 
2561 #endif /* LDAP_CONTROL_X_SESSION_TRACKING */
2562 
2563 /*
2564  * in msctrl.c
2565  */
2566 #ifdef LDAP_CONTROL_X_DIRSYNC
2567 LDAP_F( int )
2568 ldap_create_dirsync_value LDAP_P((
2569     LDAP        *ld,
2570     int     flags,
2571     int     maxAttrCount,
2572     struct berval   *cookie,
2573     struct berval   *value ));
2574 
2575 LDAP_F( int )
2576 ldap_create_dirsync_control LDAP_P((
2577     LDAP        *ld,
2578     int     flags,
2579     int     maxAttrCount,
2580     struct berval   *cookie,
2581     LDAPControl **ctrlp ));
2582 
2583 LDAP_F( int )
2584 ldap_parse_dirsync_control LDAP_P((
2585     LDAP        *ld,
2586     LDAPControl *ctrl,
2587     int     *continueFlag,
2588     struct berval   *cookie ));
2589 #endif /* LDAP_CONTROL_X_DIRSYNC */
2590 
2591 #ifdef LDAP_CONTROL_X_EXTENDED_DN
2592 LDAP_F( int )
2593 ldap_create_extended_dn_value LDAP_P((
2594     LDAP        *ld,
2595     int     flag,
2596     struct berval   *value ));
2597 
2598 LDAP_F( int )
2599 ldap_create_extended_dn_control LDAP_P((
2600     LDAP        *ld,
2601     int     flag,
2602     LDAPControl **ctrlp ));
2603 #endif /* LDAP_CONTROL_X_EXTENDED_DN */
2604 
2605 #ifdef LDAP_CONTROL_X_SHOW_DELETED
2606 LDAP_F( int )
2607 ldap_create_show_deleted_control LDAP_P((
2608     LDAP        *ld,
2609     LDAPControl **ctrlp ));
2610 #endif /* LDAP_CONTROL_X_SHOW_DELETED */
2611 
2612 #ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
2613 LDAP_F( int )
2614 ldap_create_server_notification_control LDAP_P((
2615     LDAP        *ld,
2616     LDAPControl **ctrlp ));
2617 #endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */
2618 
2619 /*
2620  * in assertion.c
2621  */
2622 LDAP_F (int)
2623 ldap_create_assertion_control_value LDAP_P((
2624     LDAP        *ld,
2625     char        *assertion,
2626     struct berval   *value ));
2627 
2628 LDAP_F( int )
2629 ldap_create_assertion_control LDAP_P((
2630     LDAP        *ld,
2631     char        *filter,
2632     int     iscritical,
2633     LDAPControl **ctrlp ));
2634 
2635 /*
2636  * in deref.c
2637  */
2638 
2639 typedef struct LDAPDerefSpec {
2640     char *derefAttr;
2641     char **attributes;
2642 } LDAPDerefSpec;
2643 
2644 typedef struct LDAPDerefVal {
2645     char *type;
2646     BerVarray vals;
2647     struct LDAPDerefVal *next;
2648 } LDAPDerefVal;
2649 
2650 typedef struct LDAPDerefRes {
2651     char *derefAttr;
2652     struct berval derefVal;
2653     LDAPDerefVal *attrVals;
2654     struct LDAPDerefRes *next;
2655 } LDAPDerefRes;
2656 
2657 LDAP_F( int )
2658 ldap_create_deref_control_value LDAP_P((
2659     LDAP *ld,
2660     LDAPDerefSpec *ds,
2661     struct berval *value ));
2662 
2663 LDAP_F( int )
2664 ldap_create_deref_control LDAP_P((
2665     LDAP        *ld,
2666     LDAPDerefSpec   *ds,
2667     int     iscritical,
2668     LDAPControl **ctrlp ));
2669 
2670 LDAP_F( void )
2671 ldap_derefresponse_free LDAP_P((
2672     LDAPDerefRes *dr ));
2673 
2674 LDAP_F( int )
2675 ldap_parse_derefresponse_control LDAP_P((
2676     LDAP *ld,
2677     LDAPControl *ctrl,
2678     LDAPDerefRes **drp ));
2679 
2680 LDAP_F( int )
2681 ldap_parse_deref_control LDAP_P((
2682     LDAP        *ld,
2683     LDAPControl **ctrls,
2684     LDAPDerefRes    **drp ));
2685 
2686 /*
2687  * in psearch.c
2688  */
2689 
2690 LDAP_F( int )
2691 ldap_create_persistentsearch_control_value LDAP_P((
2692     LDAP *ld,
2693     int changetypes,
2694     int changesonly,
2695     int return_echg_ctls,
2696     struct berval *value ));
2697 
2698 LDAP_F( int )
2699 ldap_create_persistentsearch_control LDAP_P((
2700     LDAP *ld,
2701     int changetypes,
2702     int changesonly,
2703     int return_echg_ctls,
2704     int isCritical,
2705     LDAPControl **ctrlp ));
2706 
2707 LDAP_F( int )
2708 ldap_parse_entrychange_control LDAP_P((
2709     LDAP *ld,
2710     LDAPControl *ctrl,
2711     int *chgtypep,
2712     struct berval *prevdnp,
2713     int *chgnumpresentp,
2714     long *chgnump ));
2715 
2716 /* in account_usability.c */
2717 
2718 LDAP_F( int )
2719 ldap_create_accountusability_control LDAP_P((
2720     LDAP *ld,
2721     LDAPControl **ctrlp ));
2722 
2723 typedef struct LDAPAccountUsabilityMoreInfo {
2724     ber_int_t inactive;
2725     ber_int_t reset;
2726     ber_int_t expired;
2727     ber_int_t remaining_grace;
2728     ber_int_t seconds_before_unlock;
2729 } LDAPAccountUsabilityMoreInfo;
2730 
2731 typedef union LDAPAccountUsability {
2732     ber_int_t seconds_remaining;
2733     LDAPAccountUsabilityMoreInfo more_info;
2734 } LDAPAccountUsability;
2735 
2736 LDAP_F( int )
2737 ldap_parse_accountusability_control LDAP_P((
2738     LDAP           *ld,
2739     LDAPControl    *ctrl,
2740     int            *availablep,
2741     LDAPAccountUsability *usabilityp ));
2742 
2743 
2744 /*
2745  * high level LDIF to LDAP structure support
2746  */
2747 #define LDIF_DEFAULT_ADD  0x01 /* if changetype missing, assume LDAP_ADD */
2748 #define LDIF_ENTRIES_ONLY 0x02 /* ignore changetypes other than add */
2749 #define LDIF_NO_CONTROLS  0x04 /* ignore control specifications */
2750 #define LDIF_MODS_ONLY    0x08 /* no changetypes, assume LDAP_MODIFY */
2751 #define LDIF_NO_DN        0x10 /* dn is not present */
2752 
2753 typedef struct ldifrecord {
2754     ber_tag_t lr_op; /* type of operation - LDAP_REQ_MODIFY, LDAP_REQ_ADD, etc. */
2755     struct berval lr_dn; /* DN of operation */
2756     LDAPControl **lr_ctrls; /* controls specified for operation */
2757     /* some ops such as LDAP_REQ_DELETE require only a DN */
2758     /* other ops require different data - the ldif_ops union
2759        is used to specify the data for each type of operation */
2760     union ldif_ops_u {
2761         LDAPMod **lr_mods; /* list of mods for LDAP_REQ_MODIFY, LDAP_REQ_ADD */
2762 #define lrop_mods ldif_ops.lr_mods
2763         struct ldif_op_rename_s {
2764             struct berval lr_newrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
2765 #define lrop_newrdn ldif_ops.ldif_op_rename.lr_newrdn
2766             struct berval lr_newsuperior; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
2767 #define lrop_newsup ldif_ops.ldif_op_rename.lr_newsuperior
2768             int lr_deleteoldrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */
2769 #define lrop_delold ldif_ops.ldif_op_rename.lr_deleteoldrdn
2770         } ldif_op_rename; /* rename/moddn/modrdn */
2771         /* the following are for future support */
2772         struct ldif_op_ext_s {
2773             struct berval lr_extop_oid; /* LDAP_REQ_EXTENDED */
2774 #define lrop_extop_oid ldif_ops.ldif_op_ext.lr_extop_oid
2775             struct berval lr_extop_data; /* LDAP_REQ_EXTENDED */
2776 #define lrop_extop_data ldif_ops.ldif_op_ext.lr_extop_data
2777         } ldif_op_ext; /* extended operation */
2778         struct ldif_op_cmp_s {
2779             struct berval lr_cmp_attr; /* LDAP_REQ_COMPARE */
2780 #define lrop_cmp_attr ldif_ops.ldif_op_cmp.lr_cmp_attr
2781             struct berval lr_cmp_bvalue; /* LDAP_REQ_COMPARE */
2782 #define lrop_cmp_bval ldif_ops.ldif_op_cmp.lr_cmp_bvalue
2783         } ldif_op_cmp; /* compare operation */
2784     } ldif_ops;
2785     /* PRIVATE STUFF - DO NOT TOUCH */
2786     /* for efficiency, the implementation allocates memory */
2787     /* in large blobs, and makes the above fields point to */
2788     /* locations inside those blobs - one consequence is that */
2789     /* you cannot simply free the above allocated fields, nor */
2790     /* assign them to be owned by another memory context which */
2791     /* might free them (unless providing your own mem ctx) */
2792     /* we use the fields below to keep track of those blobs */
2793     /* so we that we can free them later */
2794     void *lr_ctx; /* the memory context or NULL */
2795     int lr_lines;
2796     LDAPMod *lr_lm;
2797     unsigned char *lr_mops;
2798     char *lr_freeval;
2799     struct berval *lr_vals;
2800     struct berval *lr_btype;
2801 } LDIFRecord;
2802 
2803 /* free internal fields - does not free the LDIFRecord */
2804 LDAP_F( void )
2805 ldap_ldif_record_done LDAP_P((
2806     LDIFRecord *lr ));
2807 
2808 LDAP_F( int )
2809 ldap_parse_ldif_record LDAP_P((
2810     struct berval *rbuf,
2811     unsigned long linenum,
2812     LDIFRecord *lr,
2813     const char *errstr,
2814     unsigned int flags ));
2815 
2816 LDAP_END_DECL
2817 #endif /* _LDAP_H */