11 static const char* features[] = {
12 #ifdef LDAP_API_FEATURE_THREAD_SAFE
15 #ifdef LDAP_API_FEATURE_SESSION_THREAD_SAFE
16 "SESSION_THREAD_SAFE",
18 #ifdef LDAP_API_FEATURE_OPERATION_THREAD_SAFE
19 "OPERATION_THREAD_SAFE",
21 #ifdef LDAP_API_FEATURE_X_OPENLDAP_REEENTRANT
22 "X_OPENLDAP_REENTRANT",
24 #if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) && \
25 defined( LDAP_THREAD_SAFE )
26 "X_OPENLDAP_THREAD_SAFE",
28 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
31 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
32 "X_OPENLDAP_V2_REFERRALS",
43 struct ldapoptions *lo;
45 if(!openldap_ldap_initialized) {
46 openldap_ldap_initialize();
49 if(outvalue == NULL) {
50 /* no place to get to */
55 lo = &openldap_ldap_global_options;
61 case LDAP_OPT_API_INFO: {
62 struct ldapapiinfo *info = (struct ldapapiinfo *) outvalue;
65 /* outvalue must point to an apiinfo structure */
69 if(info->ldapai_info_version != LDAP_API_INFO_VERSION) {
70 /* api info version mismatch */
71 info->ldapai_info_version = LDAP_API_INFO_VERSION;
75 info->ldapai_api_version = LDAP_API_VERSION;
76 info->ldapai_api_version = LDAP_API_VERSION;
77 info->ldapai_protocol_version = LDAP_VERSION_MAX;
78 if(features[0] == NULL) {
79 info->ldapai_extensions = NULL;
82 info->ldapai_extensions = malloc(sizeof(features));
84 for(i=0; features[i] != NULL; i++) {
85 info->ldapai_extensions[i] =
86 ldap_strdup(features[i]);
89 info->ldapai_extensions[i] = NULL;
92 info->ldapai_vendor_name = ldap_strdup(LDAP_VENDOR_NAME);
93 info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
104 * (int *) outvalue = ld->ld_sb.sb_sd;
108 * (int *) outvalue = lo->ldo_deref;
111 case LDAP_OPT_SIZELIMIT:
112 * (int *) outvalue = lo->ldo_sizelimit;
115 case LDAP_OPT_TIMELIMIT:
116 * (int *) outvalue = lo->ldo_timelimit;
119 case LDAP_OPT_REFERRALS:
120 * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_REFERRALS);
123 case LDAP_OPT_RESTART:
124 * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_RESTART);
127 case LDAP_OPT_DNS: /* LDAPv2 */
128 * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_DNS);
131 case LDAP_OPT_PROTOCOL_VERSION:
132 if ((ld != NULL) && ld->ld_version) {
133 * (int *) outvalue = ld->ld_version;
135 * (int *) outvalue = lo->ldo_version;
139 case LDAP_OPT_SERVER_CONTROLS:
140 case LDAP_OPT_CLIENT_CONTROLS:
141 /* not yet supported */
144 case LDAP_OPT_HOST_NAME:
146 * draft-ietf-ldapext-ldap-c-api-01 doesn't state
147 * whether client to have to free host names or no,
151 * (char **) outvalue = ldap_strdup(lo->ldo_defhost);
154 case LDAP_OPT_ERROR_NUMBER:
159 * (int *) outvalue = ld->ld_errno;
162 case LDAP_OPT_ERROR_STRING:
163 /* not yet supported */
170 * draft-ietf-ldapext-ldap-c-api-01 doesn't require
171 * the client to have to free error strings, we do
174 if( ld->ld_error == NULL ) {
175 * (char **) outvalue = NULL;
177 * (char **) outvalue = ldap_strdup(ld->ld_error);
195 struct ldapoptions *lo;
197 if(!openldap_ldap_initialized) {
198 openldap_ldap_initialize();
201 if(invalue == NULL) {
202 /* no place to set from */
207 lo = &openldap_ldap_global_options;
209 lo = &ld->ld_options;
213 case LDAP_OPT_API_INFO:
219 lo->ldo_deref = * (int *) invalue;
222 case LDAP_OPT_SIZELIMIT:
223 lo->ldo_sizelimit = * (int *) invalue;
226 case LDAP_OPT_TIMELIMIT:
227 lo->ldo_timelimit = * (int *) invalue;
230 case LDAP_OPT_REFERRALS:
231 if((int) invalue == (int) LDAP_OPT_ON) {
232 LDAP_BOOL_SET(lo, LDAP_BOOL_REFERRALS);
234 LDAP_BOOL_CLR(lo, LDAP_BOOL_REFERRALS);
238 case LDAP_OPT_RESTART:
239 if((int) invalue == (int) LDAP_OPT_ON) {
240 LDAP_BOOL_SET(lo, LDAP_BOOL_RESTART);
242 LDAP_BOOL_CLR(lo, LDAP_BOOL_RESTART);
246 case LDAP_OPT_PROTOCOL_VERSION: {
247 int vers = * (int *) invalue;
248 if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
252 ld->ld_version = vers;
255 case LDAP_OPT_SERVER_CONTROLS:
256 case LDAP_OPT_CLIENT_CONTROLS:
257 /* not yet supported */
260 case LDAP_OPT_HOST_NAME: {
261 char* host = * (char **) invalue;
263 if(lo->ldo_defhost != NULL) {
264 free(lo->ldo_defhost);
265 lo->ldo_defhost = NULL;
269 lo->ldo_defhost = ldap_strdup(host);
275 * must want global default returned
276 * to initial condition.
278 lo->ldo_defhost = ldap_strdup("localhost");
282 * must want the session default
283 * updated to the current global default
285 lo->ldo_defhost = ldap_strdup(
286 openldap_ldap_global_options.ldo_defhost);
290 case LDAP_OPT_ERROR_NUMBER: {
291 int err = * (int *) invalue;
295 /* we only allow ld_errno to be cleared. */
300 /* need a struct ldap */
307 case LDAP_OPT_ERROR_STRING: {
308 char* err = * (char **) invalue;
312 /* we only allow ld_error to be cleared. */
317 /* need a struct ldap */