1998-12-29 04:53:15 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include "ldap-int.h"
|
|
|
|
|
1998-12-22 11:17:25 +08:00
|
|
|
static const LDAPAPIFeatureInfo features[] = {
|
1999-05-19 09:12:33 +08:00
|
|
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP
|
|
|
|
{ /* OpenLDAP Extensions API Feature */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"X_OPENLDAP",
|
|
|
|
LDAP_API_FEATURE_X_OPENLDAP
|
|
|
|
},
|
1998-12-22 11:17:25 +08:00
|
|
|
#endif
|
1999-05-19 09:12:33 +08:00
|
|
|
|
1998-12-20 08:58:55 +08:00
|
|
|
#ifdef LDAP_API_FEATURE_THREAD_SAFE
|
1999-05-19 09:12:33 +08:00
|
|
|
{ /* Basic Thread Safe */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"THREAD_SAFE",
|
|
|
|
LDAP_API_FEATURE_THREAD_SAFE
|
|
|
|
},
|
1998-12-20 08:58:55 +08:00
|
|
|
#endif
|
|
|
|
#ifdef LDAP_API_FEATURE_SESSION_THREAD_SAFE
|
1999-05-19 09:12:33 +08:00
|
|
|
{ /* Session Thread Safe */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"SESSION_THREAD_SAFE",
|
|
|
|
LDAP_API_FEATURE_SESSION_THREAD_SAFE
|
|
|
|
},
|
1998-12-20 08:58:55 +08:00
|
|
|
#endif
|
|
|
|
#ifdef LDAP_API_FEATURE_OPERATION_THREAD_SAFE
|
1999-05-19 09:12:33 +08:00
|
|
|
{ /* Operation Thread Safe */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"OPERATION_THREAD_SAFE",
|
|
|
|
LDAP_API_FEATURE_OPERATION_THREAD_SAFE
|
|
|
|
},
|
1998-12-20 08:58:55 +08:00
|
|
|
#endif
|
1999-04-30 19:48:36 +08:00
|
|
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
|
1999-05-19 09:12:33 +08:00
|
|
|
{ /* OpenLDAP Reentrant */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"X_OPENLDAP_REENTRANT",
|
|
|
|
LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
|
|
|
|
},
|
1998-12-20 08:58:55 +08:00
|
|
|
#endif
|
|
|
|
#if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) && \
|
|
|
|
defined( LDAP_THREAD_SAFE )
|
1999-05-19 09:12:33 +08:00
|
|
|
{ /* OpenLDAP Thread Safe */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"X_OPENLDAP_THREAD_SAFE",
|
|
|
|
LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
|
|
|
|
},
|
1998-12-20 08:58:55 +08:00
|
|
|
#endif
|
1998-11-10 07:21:38 +08:00
|
|
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
|
1999-05-19 09:12:33 +08:00
|
|
|
{ /* DNS */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"X_OPENLDAP_V2_DNS",
|
|
|
|
LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
|
|
|
|
},
|
1998-11-10 07:21:38 +08:00
|
|
|
#endif
|
|
|
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
1999-05-19 09:12:33 +08:00
|
|
|
{ /* V2 Referrals */
|
|
|
|
LDAP_FEATURE_INFO_VERSION,
|
|
|
|
"X_OPENLDAP_V2_REFERRALS",
|
|
|
|
LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
|
|
|
|
},
|
1998-11-10 07:21:38 +08:00
|
|
|
#endif
|
1999-05-19 09:12:33 +08:00
|
|
|
{0, NULL, 0}
|
1998-11-10 07:21:38 +08:00
|
|
|
};
|
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
int
|
|
|
|
ldap_get_option(
|
1999-06-03 05:38:48 +08:00
|
|
|
LDAP_CONST LDAP *ld,
|
1998-11-04 09:41:00 +08:00
|
|
|
int option,
|
|
|
|
void *outvalue)
|
|
|
|
{
|
1999-06-03 05:38:48 +08:00
|
|
|
LDAP_CONST struct ldapoptions *lo;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
if( ldap_int_global_options.ldo_valid != LDAP_INITIALIZED ) {
|
|
|
|
ldap_int_initialize();
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if(outvalue == NULL) {
|
|
|
|
/* no place to get to */
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_ERROR;
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
1998-11-10 02:40:37 +08:00
|
|
|
if(ld == NULL) {
|
1999-05-29 03:33:05 +08:00
|
|
|
lo = &ldap_int_global_options;
|
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
} else {
|
1999-05-29 03:33:05 +08:00
|
|
|
assert( LDAP_VALID( ld ) );
|
|
|
|
|
|
|
|
if( !LDAP_VALID( ld ) ) {
|
|
|
|
return LDAP_OPT_ERROR;
|
|
|
|
}
|
|
|
|
|
1998-11-10 02:40:37 +08:00
|
|
|
lo = &ld->ld_options;
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(option) {
|
|
|
|
case LDAP_OPT_API_INFO: {
|
|
|
|
struct ldapapiinfo *info = (struct ldapapiinfo *) outvalue;
|
|
|
|
|
|
|
|
if(info == NULL) {
|
|
|
|
/* outvalue must point to an apiinfo structure */
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_ERROR;
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
1998-11-05 04:08:37 +08:00
|
|
|
if(info->ldapai_info_version != LDAP_API_INFO_VERSION) {
|
|
|
|
/* api info version mismatch */
|
|
|
|
info->ldapai_info_version = LDAP_API_INFO_VERSION;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_ERROR;
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
1998-11-05 04:08:37 +08:00
|
|
|
info->ldapai_api_version = LDAP_API_VERSION;
|
1998-11-04 09:41:00 +08:00
|
|
|
info->ldapai_api_version = LDAP_API_VERSION;
|
|
|
|
info->ldapai_protocol_version = LDAP_VERSION_MAX;
|
1998-12-22 11:17:25 +08:00
|
|
|
|
|
|
|
if(features[0].ldapaif_name == NULL) {
|
1998-11-10 07:21:38 +08:00
|
|
|
info->ldapai_extensions = NULL;
|
|
|
|
} else {
|
|
|
|
int i;
|
1999-05-29 09:19:14 +08:00
|
|
|
info->ldapai_extensions = LDAP_MALLOC(sizeof(char *) *
|
1998-12-22 11:17:25 +08:00
|
|
|
sizeof(features)/sizeof(LDAPAPIFeatureInfo));
|
1998-11-10 07:21:38 +08:00
|
|
|
|
1998-12-22 11:17:25 +08:00
|
|
|
for(i=0; features[i].ldapaif_name != NULL; i++) {
|
1998-11-19 14:18:23 +08:00
|
|
|
info->ldapai_extensions[i] =
|
1999-06-03 06:28:22 +08:00
|
|
|
LDAP_STRDUP(features[i].ldapaif_name);
|
1998-11-10 07:21:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
info->ldapai_extensions[i] = NULL;
|
|
|
|
}
|
|
|
|
|
1999-06-03 06:28:22 +08:00
|
|
|
info->ldapai_vendor_name = LDAP_STRDUP(LDAP_VENDOR_NAME);
|
1998-11-04 09:41:00 +08:00
|
|
|
info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
|
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case LDAP_OPT_DESC:
|
1998-11-10 02:40:37 +08:00
|
|
|
if(ld == NULL) {
|
1998-11-04 09:41:00 +08:00
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-05-19 09:12:33 +08:00
|
|
|
* (int *) outvalue = ber_pvt_sb_get_desc( &(ld->ld_sb) );
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_DEREF:
|
1998-11-10 02:40:37 +08:00
|
|
|
* (int *) outvalue = lo->ldo_deref;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_SIZELIMIT:
|
1998-11-10 02:40:37 +08:00
|
|
|
* (int *) outvalue = lo->ldo_sizelimit;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_TIMELIMIT:
|
1998-11-10 02:40:37 +08:00
|
|
|
* (int *) outvalue = lo->ldo_timelimit;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_REFERRALS:
|
1999-06-01 01:30:22 +08:00
|
|
|
* (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_REFERRALS);
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_RESTART:
|
1999-06-01 01:30:22 +08:00
|
|
|
* (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_RESTART);
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_DNS: /* LDAPv2 */
|
1999-06-01 01:30:22 +08:00
|
|
|
* (int *) outvalue = (int) LDAP_BOOL_GET(lo, LDAP_BOOL_DNS);
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_PROTOCOL_VERSION:
|
1998-11-11 07:37:30 +08:00
|
|
|
if ((ld != NULL) && ld->ld_version) {
|
|
|
|
* (int *) outvalue = ld->ld_version;
|
|
|
|
} else {
|
|
|
|
* (int *) outvalue = lo->ldo_version;
|
|
|
|
}
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_SERVER_CONTROLS:
|
1998-12-23 10:30:44 +08:00
|
|
|
* (LDAPControl ***) outvalue =
|
1999-05-19 09:12:33 +08:00
|
|
|
ldap_controls_dup( lo->ldo_sctrls );
|
1998-12-23 10:30:44 +08:00
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-12-23 08:42:38 +08:00
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
case LDAP_OPT_CLIENT_CONTROLS:
|
1998-12-23 10:30:44 +08:00
|
|
|
* (LDAPControl ***) outvalue =
|
1999-05-19 09:12:33 +08:00
|
|
|
ldap_controls_dup( lo->ldo_cctrls );
|
1998-12-23 10:30:44 +08:00
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_HOST_NAME:
|
1998-11-11 07:37:30 +08:00
|
|
|
/*
|
|
|
|
* draft-ietf-ldapext-ldap-c-api-01 doesn't state
|
1998-12-23 10:30:44 +08:00
|
|
|
* whether caller has to free host names or not,
|
|
|
|
* we do.
|
1998-11-11 07:37:30 +08:00
|
|
|
*/
|
|
|
|
|
1999-06-03 06:28:22 +08:00
|
|
|
* (char **) outvalue = LDAP_STRDUP(lo->ldo_defhost);
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_ERROR_NUMBER:
|
1998-11-10 02:40:37 +08:00
|
|
|
if(ld == NULL) {
|
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
1998-11-04 09:41:00 +08:00
|
|
|
* (int *) outvalue = ld->ld_errno;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_ERROR_STRING:
|
1998-11-10 02:40:37 +08:00
|
|
|
if(ld == NULL) {
|
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
1998-11-11 07:37:30 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* draft-ietf-ldapext-ldap-c-api-01 doesn't require
|
|
|
|
* the client to have to free error strings, we do
|
|
|
|
*/
|
|
|
|
|
|
|
|
if( ld->ld_error == NULL ) {
|
|
|
|
* (char **) outvalue = NULL;
|
|
|
|
} else {
|
1999-06-03 06:28:22 +08:00
|
|
|
* (char **) outvalue = LDAP_STRDUP(ld->ld_error);
|
1998-11-11 07:37:30 +08:00
|
|
|
}
|
1998-12-23 10:30:44 +08:00
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
1999-05-26 10:35:20 +08:00
|
|
|
case LDAP_OPT_MATCH_STRING:
|
|
|
|
if(ld == NULL) {
|
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* draft-ietf-ldapext-ldap-c-api-01 doesn't require
|
|
|
|
* the client to have to free error strings, we do
|
|
|
|
*/
|
|
|
|
|
|
|
|
if( ld->ld_matched == NULL ) {
|
|
|
|
* (char **) outvalue = NULL;
|
|
|
|
} else {
|
1999-06-03 06:28:22 +08:00
|
|
|
* (char **) outvalue = LDAP_STRDUP(ld->ld_matched);
|
1999-05-26 10:35:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
1998-12-22 11:17:25 +08:00
|
|
|
case LDAP_OPT_API_FEATURE_INFO: {
|
|
|
|
LDAPAPIFeatureInfo *info = (LDAPAPIFeatureInfo *) outvalue;
|
|
|
|
int i;
|
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
if(info == NULL) return LDAP_OPT_ERROR;
|
1999-05-19 09:12:33 +08:00
|
|
|
|
|
|
|
if(info->ldapaif_info_version != LDAP_FEATURE_INFO_VERSION) {
|
|
|
|
/* api info version mismatch */
|
|
|
|
info->ldapaif_info_version = LDAP_FEATURE_INFO_VERSION;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_ERROR;
|
1999-05-19 09:12:33 +08:00
|
|
|
}
|
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
if(info->ldapaif_name == NULL) return LDAP_OPT_ERROR;
|
1998-12-22 11:17:25 +08:00
|
|
|
|
|
|
|
for(i=0; features[i].ldapaif_name != NULL; i++) {
|
|
|
|
if(!strcmp(info->ldapaif_name, features[i].ldapaif_name)) {
|
|
|
|
info->ldapaif_version =
|
|
|
|
features[i].ldapaif_version;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-12-22 11:17:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-12-22 09:34:01 +08:00
|
|
|
case LDAP_OPT_DEBUG_LEVEL:
|
|
|
|
* (int *) outvalue = lo->ldo_debug;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-12-22 09:34:01 +08:00
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
default:
|
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_ERROR;
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ldap_set_option(
|
1998-11-10 02:40:37 +08:00
|
|
|
LDAP *ld,
|
1998-11-04 09:41:00 +08:00
|
|
|
int option,
|
1999-05-19 09:52:46 +08:00
|
|
|
LDAP_CONST void *invalue)
|
1998-11-04 09:41:00 +08:00
|
|
|
{
|
1998-11-10 02:40:37 +08:00
|
|
|
struct ldapoptions *lo;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
if( ldap_int_global_options.ldo_valid != LDAP_INITIALIZED ) {
|
|
|
|
ldap_int_initialize();
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
1998-11-10 02:40:37 +08:00
|
|
|
if(ld == NULL) {
|
1999-05-29 03:33:05 +08:00
|
|
|
lo = &ldap_int_global_options;
|
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
} else {
|
1999-05-29 03:33:05 +08:00
|
|
|
assert( LDAP_VALID( ld ) );
|
|
|
|
|
|
|
|
if( !LDAP_VALID( ld ) ) {
|
|
|
|
return LDAP_OPT_ERROR;
|
|
|
|
}
|
|
|
|
|
1998-11-10 02:40:37 +08:00
|
|
|
lo = &ld->ld_options;
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|
|
|
|
|
1999-03-09 15:49:56 +08:00
|
|
|
switch(option) {
|
|
|
|
case LDAP_OPT_REFERRALS:
|
1999-06-01 01:30:22 +08:00
|
|
|
if(invalue == LDAP_OPT_OFF) {
|
1999-03-09 15:49:56 +08:00
|
|
|
LDAP_BOOL_CLR(lo, LDAP_BOOL_REFERRALS);
|
1999-06-01 01:30:22 +08:00
|
|
|
} else {
|
|
|
|
LDAP_BOOL_SET(lo, LDAP_BOOL_REFERRALS);
|
1999-03-09 15:49:56 +08:00
|
|
|
}
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1999-03-09 15:49:56 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_RESTART:
|
1999-06-01 01:30:22 +08:00
|
|
|
if(invalue == LDAP_OPT_OFF) {
|
1999-03-09 15:49:56 +08:00
|
|
|
LDAP_BOOL_CLR(lo, LDAP_BOOL_RESTART);
|
1999-06-01 01:30:22 +08:00
|
|
|
} else {
|
|
|
|
LDAP_BOOL_SET(lo, LDAP_BOOL_RESTART);
|
1999-03-09 15:49:56 +08:00
|
|
|
}
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1999-03-09 15:49:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if(invalue == NULL) {
|
|
|
|
/* no place to set from */
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_ERROR;
|
1999-03-09 15:49:56 +08:00
|
|
|
}
|
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
switch(option) {
|
|
|
|
case LDAP_OPT_API_INFO:
|
|
|
|
case LDAP_OPT_DESC:
|
|
|
|
/* READ ONLY */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LDAP_OPT_DEREF:
|
1998-11-10 02:40:37 +08:00
|
|
|
lo->ldo_deref = * (int *) invalue;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_SIZELIMIT:
|
1998-11-10 02:40:37 +08:00
|
|
|
lo->ldo_sizelimit = * (int *) invalue;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_TIMELIMIT:
|
1998-11-10 02:40:37 +08:00
|
|
|
lo->ldo_timelimit = * (int *) invalue;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_PROTOCOL_VERSION: {
|
|
|
|
int vers = * (int *) invalue;
|
1998-11-05 04:08:37 +08:00
|
|
|
if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
|
1998-11-04 09:41:00 +08:00
|
|
|
/* not supported */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ld->ld_version = vers;
|
1999-05-29 03:33:05 +08:00
|
|
|
} return LDAP_OPT_SUCCESS;
|
1998-11-04 09:41:00 +08:00
|
|
|
|
1998-12-23 08:42:38 +08:00
|
|
|
case LDAP_OPT_SERVER_CONTROLS: {
|
1998-12-23 10:30:44 +08:00
|
|
|
LDAPControl **controls = (LDAPControl **) invalue;
|
|
|
|
|
1999-05-19 09:12:33 +08:00
|
|
|
ldap_controls_free( lo->ldo_sctrls );
|
1998-12-23 10:30:44 +08:00
|
|
|
|
|
|
|
if( controls == NULL || *controls == NULL ) {
|
1999-05-19 09:12:33 +08:00
|
|
|
lo->ldo_sctrls = NULL;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-12-23 10:30:44 +08:00
|
|
|
}
|
|
|
|
|
1999-05-19 09:12:33 +08:00
|
|
|
lo->ldo_sctrls =
|
1998-12-23 10:30:44 +08:00
|
|
|
ldap_controls_dup( (LDAPControl **) invalue );
|
|
|
|
|
1999-05-19 09:12:33 +08:00
|
|
|
if(lo->ldo_sctrls == NULL) {
|
1998-12-23 10:30:44 +08:00
|
|
|
/* memory allocation error ? */
|
|
|
|
break;
|
|
|
|
}
|
1999-05-29 03:33:05 +08:00
|
|
|
} return LDAP_OPT_SUCCESS;
|
1998-12-23 08:42:38 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_CLIENT_CONTROLS: {
|
1998-12-23 10:30:44 +08:00
|
|
|
LDAPControl **controls = (LDAPControl **) invalue;
|
|
|
|
|
1999-05-19 09:12:33 +08:00
|
|
|
ldap_controls_free( lo->ldo_cctrls );
|
1998-12-23 10:30:44 +08:00
|
|
|
|
|
|
|
if( controls == NULL || *controls == NULL ) {
|
1999-05-19 09:12:33 +08:00
|
|
|
lo->ldo_cctrls = NULL;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-12-23 10:30:44 +08:00
|
|
|
}
|
|
|
|
|
1999-05-19 09:12:33 +08:00
|
|
|
lo->ldo_cctrls =
|
1998-12-23 10:30:44 +08:00
|
|
|
ldap_controls_dup( (LDAPControl **) invalue );
|
|
|
|
|
1999-05-19 09:12:33 +08:00
|
|
|
if(lo->ldo_cctrls == NULL) {
|
1998-12-23 10:30:44 +08:00
|
|
|
/* memory allocation error ? */
|
|
|
|
break;
|
|
|
|
}
|
1999-05-29 03:33:05 +08:00
|
|
|
} return LDAP_OPT_SUCCESS;
|
1998-11-11 07:37:30 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_HOST_NAME: {
|
1998-12-23 08:42:38 +08:00
|
|
|
char* host = (char *) invalue;
|
1998-11-11 07:37:30 +08:00
|
|
|
|
|
|
|
if(lo->ldo_defhost != NULL) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE(lo->ldo_defhost);
|
1998-11-11 07:37:30 +08:00
|
|
|
lo->ldo_defhost = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(host != NULL) {
|
1999-06-03 06:28:22 +08:00
|
|
|
lo->ldo_defhost = LDAP_STRDUP(host);
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-11-11 07:37:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ld == NULL) {
|
|
|
|
/*
|
|
|
|
* must want global default returned
|
|
|
|
* to initial condition.
|
|
|
|
*/
|
1999-06-03 06:28:22 +08:00
|
|
|
lo->ldo_defhost = LDAP_STRDUP("localhost");
|
1998-11-11 07:37:30 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* must want the session default
|
|
|
|
* updated to the current global default
|
|
|
|
*/
|
1999-06-03 06:28:22 +08:00
|
|
|
lo->ldo_defhost = LDAP_STRDUP(
|
1999-05-29 03:33:05 +08:00
|
|
|
ldap_int_global_options.ldo_defhost);
|
1998-11-11 07:37:30 +08:00
|
|
|
}
|
1999-05-29 03:33:05 +08:00
|
|
|
} return LDAP_OPT_SUCCESS;
|
1998-11-11 07:37:30 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_ERROR_NUMBER: {
|
|
|
|
int err = * (int *) invalue;
|
|
|
|
|
|
|
|
if(ld == NULL) {
|
|
|
|
/* need a struct ldap */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ld->ld_errno = err;
|
1999-05-29 03:33:05 +08:00
|
|
|
} return LDAP_OPT_SUCCESS;
|
1998-11-11 07:37:30 +08:00
|
|
|
|
|
|
|
case LDAP_OPT_ERROR_STRING: {
|
1998-12-23 08:42:38 +08:00
|
|
|
char* err = (char *) invalue;
|
1998-11-11 07:37:30 +08:00
|
|
|
|
|
|
|
if(ld == NULL) {
|
|
|
|
/* need a struct ldap */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-12-22 12:49:56 +08:00
|
|
|
if( ld->ld_error ) {
|
1999-05-29 09:19:14 +08:00
|
|
|
LDAP_FREE(ld->ld_error);
|
1998-12-22 12:49:56 +08:00
|
|
|
}
|
|
|
|
|
1999-06-03 06:28:22 +08:00
|
|
|
ld->ld_error = LDAP_STRDUP(err);
|
1999-05-29 03:33:05 +08:00
|
|
|
} return LDAP_OPT_SUCCESS;
|
1998-11-11 07:37:30 +08:00
|
|
|
|
1998-12-22 11:17:25 +08:00
|
|
|
case LDAP_OPT_API_FEATURE_INFO:
|
|
|
|
/* read-only */
|
|
|
|
break;
|
|
|
|
|
1998-12-22 09:34:01 +08:00
|
|
|
case LDAP_OPT_DEBUG_LEVEL:
|
|
|
|
lo->ldo_debug = * (int *) invalue;
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_SUCCESS;
|
1998-12-22 09:34:01 +08:00
|
|
|
|
1998-11-04 09:41:00 +08:00
|
|
|
default:
|
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
1999-05-29 03:33:05 +08:00
|
|
|
return LDAP_OPT_ERROR;
|
1998-11-04 09:41:00 +08:00
|
|
|
}
|