11 static const char* features[] = {
12 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
15 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
16 "X_OPENLDAP_V2_REFERRALS",
27 struct ldapoptions *lo;
29 if(!openldap_ldap_initialized) {
30 openldap_ldap_initialize();
33 if(outvalue == NULL) {
34 /* no place to get to */
39 lo = &openldap_ldap_global_options;
45 case LDAP_OPT_API_INFO: {
46 struct ldapapiinfo *info = (struct ldapapiinfo *) outvalue;
49 /* outvalue must point to an apiinfo structure */
53 if(info->ldapai_info_version != LDAP_API_INFO_VERSION) {
54 /* api info version mismatch */
55 info->ldapai_info_version = LDAP_API_INFO_VERSION;
59 info->ldapai_api_version = LDAP_API_VERSION;
60 info->ldapai_api_version = LDAP_API_VERSION;
61 info->ldapai_protocol_version = LDAP_VERSION_MAX;
62 if(features[0] == NULL) {
63 info->ldapai_extensions = NULL;
66 info->ldapai_extensions = malloc(sizeof(features));
68 for(i=0; features[i] != NULL; i++) {
69 info->ldapai_extensions[i] =
70 ldap_strdup(features[i]);
73 info->ldapai_extensions[i] = NULL;
76 info->ldapai_vendor_name = ldap_strdup(LDAP_VENDOR_NAME);
77 info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
88 * (int *) outvalue = ld->ld_sb.sb_sd;
92 * (int *) outvalue = lo->ldo_deref;
95 case LDAP_OPT_SIZELIMIT:
96 * (int *) outvalue = lo->ldo_sizelimit;
99 case LDAP_OPT_TIMELIMIT:
100 * (int *) outvalue = lo->ldo_timelimit;
103 case LDAP_OPT_REFERRALS:
104 * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_REFERRALS);
107 case LDAP_OPT_RESTART:
108 * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_RESTART);
111 case LDAP_OPT_DNS: /* LDAPv2 */
112 * (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_DNS);
115 case LDAP_OPT_PROTOCOL_VERSION:
116 if ((ld != NULL) && ld->ld_version) {
117 * (int *) outvalue = ld->ld_version;
119 * (int *) outvalue = lo->ldo_version;
123 case LDAP_OPT_SERVER_CONTROLS:
124 case LDAP_OPT_CLIENT_CONTROLS:
125 /* not yet supported */
128 case LDAP_OPT_HOST_NAME:
130 * draft-ietf-ldapext-ldap-c-api-01 doesn't state
131 * whether client to have to free host names or no,
135 * (char **) outvalue = ldap_strdup(lo->ldo_defhost);
138 case LDAP_OPT_ERROR_NUMBER:
143 * (int *) outvalue = ld->ld_errno;
146 case LDAP_OPT_ERROR_STRING:
147 /* not yet supported */
154 * draft-ietf-ldapext-ldap-c-api-01 doesn't require
155 * the client to have to free error strings, we do
158 if( ld->ld_error == NULL ) {
159 * (char **) outvalue = NULL;
161 * (char **) outvalue = ldap_strdup(ld->ld_error);
179 struct ldapoptions *lo;
181 if(!openldap_ldap_initialized) {
182 openldap_ldap_initialize();
185 if(invalue == NULL) {
186 /* no place to set from */
191 lo = &openldap_ldap_global_options;
193 lo = &ld->ld_options;
197 case LDAP_OPT_API_INFO:
203 lo->ldo_deref = * (int *) invalue;
206 case LDAP_OPT_SIZELIMIT:
207 lo->ldo_sizelimit = * (int *) invalue;
210 case LDAP_OPT_TIMELIMIT:
211 lo->ldo_timelimit = * (int *) invalue;
214 case LDAP_OPT_REFERRALS:
215 if((int) invalue == (int) LDAP_OPT_ON) {
216 LDAP_BOOL_SET(lo, LDAP_BOOL_REFERRALS);
218 LDAP_BOOL_CLR(lo, LDAP_BOOL_REFERRALS);
222 case LDAP_OPT_RESTART:
223 if((int) invalue == (int) LDAP_OPT_ON) {
224 LDAP_BOOL_SET(lo, LDAP_BOOL_RESTART);
226 LDAP_BOOL_CLR(lo, LDAP_BOOL_RESTART);
230 case LDAP_OPT_PROTOCOL_VERSION: {
231 int vers = * (int *) invalue;
232 if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
236 ld->ld_version = vers;
239 case LDAP_OPT_SERVER_CONTROLS:
240 case LDAP_OPT_CLIENT_CONTROLS:
241 /* not yet supported */
244 case LDAP_OPT_HOST_NAME: {
245 char* host = * (char **) invalue;
247 if(lo->ldo_defhost != NULL) {
248 free(lo->ldo_defhost);
249 lo->ldo_defhost = NULL;
253 lo->ldo_defhost = ldap_strdup(host);
259 * must want global default returned
260 * to initial condition.
262 lo->ldo_defhost = ldap_strdup("localhost");
266 * must want the session default
267 * updated to the current global default
269 lo->ldo_defhost = ldap_strdup(
270 openldap_ldap_global_options.ldo_defhost);
274 case LDAP_OPT_ERROR_NUMBER: {
275 int err = * (int *) invalue;
279 /* we only allow ld_errno to be cleared. */
284 /* need a struct ldap */
291 case LDAP_OPT_ERROR_STRING: {
292 char* err = * (char **) invalue;
296 /* we only allow ld_error to be cleared. */
301 /* need a struct ldap */