/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#define LDAP_OPT_REBIND_PROC 0x4e814d
#define LDAP_OPT_REBIND_PARAMS 0x4e814e
+#define LDAP_OPT_NEXTREF_PROC 0x4e815d
+#define LDAP_OPT_NEXTREF_PARAMS 0x4e815e
+
static const LDAPAPIFeatureInfo features[] = {
#ifdef LDAP_API_FEATURE_X_OPENLDAP
{ /* OpenLDAP Extensions API Feature */
return LDAP_OPT_ERROR;
}
- info->ldapai_api_version = LDAP_API_VERSION;
info->ldapai_api_version = LDAP_API_VERSION;
info->ldapai_protocol_version = LDAP_VERSION_MAX;
case LDAP_OPT_SOCKBUF:
if( ld == NULL ) break;
- outvalue = ld->ld_sb;
+ *(Sockbuf **)outvalue = ld->ld_sb;
return LDAP_OPT_SUCCESS;
case LDAP_OPT_TIMEOUT:
if( ld->ld_matched == NULL ) {
* (char **) outvalue = NULL;
} else {
- * (char **) outvalue = LDAP_STRDUP(ld->ld_matched);
+ * (char **) outvalue = LDAP_STRDUP( ld->ld_matched );
}
return LDAP_OPT_SUCCESS;
LDAPControl *const *controls =
(LDAPControl *const *) invalue;
- ldap_controls_free( lo->ldo_sctrls );
+ if( lo->ldo_sctrls )
+ ldap_controls_free( lo->ldo_sctrls );
if( controls == NULL || *controls == NULL ) {
lo->ldo_sctrls = NULL;
LDAPControl *const *controls =
(LDAPControl *const *) invalue;
- ldap_controls_free( lo->ldo_cctrls );
+ if( lo->ldo_cctrls )
+ ldap_controls_free( lo->ldo_cctrls );
if( controls == NULL || *controls == NULL ) {
lo->ldo_cctrls = NULL;
}
} return LDAP_OPT_SUCCESS;
- /* Only accessed from inside this function by ldap_set_rebind_proc() */
- case LDAP_OPT_REBIND_PROC: {
- lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue;
- } return LDAP_OPT_SUCCESS;
- case LDAP_OPT_REBIND_PARAMS: {
- lo->ldo_rebind_params = (void *)invalue;
- } return LDAP_OPT_SUCCESS;
- }
-
- if(invalue == NULL) {
- /* no place to set from */
- return LDAP_OPT_ERROR;
- }
-
- /* options which cannot withstand invalue == NULL */
-
- switch(option) {
- case LDAP_OPT_API_INFO:
- case LDAP_OPT_DESC:
- /* READ ONLY */
- break;
-
- case LDAP_OPT_DEREF:
- lo->ldo_deref = * (const int *) invalue;
- return LDAP_OPT_SUCCESS;
-
- case LDAP_OPT_SIZELIMIT:
- lo->ldo_sizelimit = * (const int *) invalue;
- return LDAP_OPT_SUCCESS;
-
- case LDAP_OPT_TIMELIMIT:
- lo->ldo_timelimit = * (const int *) invalue;
- return LDAP_OPT_SUCCESS;
-
- case LDAP_OPT_PROTOCOL_VERSION: {
- int vers = * (const int *) invalue;
- if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
- /* not supported */
- break;
- }
- lo->ldo_version = vers;
- } return LDAP_OPT_SUCCESS;
-
-
case LDAP_OPT_HOST_NAME: {
const char *host = (const char *) invalue;
LDAPURLDesc *ludlist = NULL;
return rc;
}
+ /* Only accessed from inside this function by ldap_set_rebind_proc() */
+ case LDAP_OPT_REBIND_PROC: {
+ lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue;
+ } return LDAP_OPT_SUCCESS;
+ case LDAP_OPT_REBIND_PARAMS: {
+ lo->ldo_rebind_params = (void *)invalue;
+ } return LDAP_OPT_SUCCESS;
+
+ /* Only accessed from inside this function by ldap_set_nextref_proc() */
+ case LDAP_OPT_NEXTREF_PROC: {
+ lo->ldo_nextref_proc = (LDAP_NEXTREF_PROC *)invalue;
+ } return LDAP_OPT_SUCCESS;
+ case LDAP_OPT_NEXTREF_PARAMS: {
+ lo->ldo_nextref_params = (void *)invalue;
+ } return LDAP_OPT_SUCCESS;
+ }
+
+ if(invalue == NULL) {
+ /* no place to set from */
+ return LDAP_OPT_ERROR;
+ }
+
+ /* options which cannot withstand invalue == NULL */
+
+ switch(option) {
+ case LDAP_OPT_API_INFO:
+ case LDAP_OPT_DESC:
+ /* READ ONLY */
+ break;
+
+ case LDAP_OPT_DEREF:
+ lo->ldo_deref = * (const int *) invalue;
+ return LDAP_OPT_SUCCESS;
+
+ case LDAP_OPT_SIZELIMIT:
+ lo->ldo_sizelimit = * (const int *) invalue;
+ return LDAP_OPT_SUCCESS;
+
+ case LDAP_OPT_TIMELIMIT:
+ lo->ldo_timelimit = * (const int *) invalue;
+ return LDAP_OPT_SUCCESS;
+
+ case LDAP_OPT_PROTOCOL_VERSION: {
+ int vers = * (const int *) invalue;
+ if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
+ /* not supported */
+ break;
+ }
+ lo->ldo_version = vers;
+ } return LDAP_OPT_SUCCESS;
+
case LDAP_OPT_ERROR_NUMBER: {
int err = * (const int *) invalue;
if( ld->ld_error ) {
LDAP_FREE(ld->ld_error);
+ ld->ld_error = NULL;
}
- ld->ld_error = LDAP_STRDUP(err);
+ if ( err ) {
+ ld->ld_error = LDAP_STRDUP(err);
+ }
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_MATCHED_DN: {
- const char *err = (const char *) invalue;
+ const char *matched = (const char *) invalue;
- if(ld == NULL) {
+ if (ld == NULL) {
/* need a struct ldap */
break;
}
if( ld->ld_matched ) {
LDAP_FREE(ld->ld_matched);
+ ld->ld_matched = NULL;
}
- ld->ld_matched = LDAP_STRDUP(err);
+ if ( matched ) {
+ ld->ld_matched = LDAP_STRDUP( matched );
+ }
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_REFERRAL_URLS: {
rc = ldap_set_option( ld, LDAP_OPT_REBIND_PARAMS, (void *)params );
return rc;
}
+
+int
+ldap_set_nextref_proc( LDAP *ld, LDAP_NEXTREF_PROC *proc, void *params )
+{
+ int rc;
+ rc = ldap_set_option( ld, LDAP_OPT_NEXTREF_PROC, (void *)proc );
+ if( rc != LDAP_OPT_SUCCESS ) return rc;
+
+ rc = ldap_set_option( ld, LDAP_OPT_NEXTREF_PARAMS, (void *)params );
+ return rc;
+}