}
if (ldif < 2 ) {
+ char *realbase = base;
+
+ if ( realbase == NULL ) {
+ ldap_get_option( ld, LDAP_OPT_DEFBASE, (void **)&realbase );
+ }
+
printf( "#\n" );
printf(_("# LDAPv%d\n"), protocol);
printf(_("# base <%s> with scope %s\n"),
- base ? base : "",
+ realbase ? realbase : "(NULL)",
((scope == LDAP_SCOPE_BASE) ? "baseObject"
: ((scope == LDAP_SCOPE_ONELEVEL) ? "oneLevel"
: ((scope == LDAP_SCOPE_SUBORDINATE) ? "children"
}
printf( _("\n#\n\n") );
+
+ if ( realbase && realbase != base ) {
+ ldap_memfree( realbase );
+ }
}
if ( infile == NULL ) {
#define LDAP_OPT_URI 0x5006
#define LDAP_OPT_REFERRAL_URLS 0x5007 /* Referral URLs */
#define LDAP_OPT_SOCKBUF 0x5008 /* sockbuf */
+#define LDAP_OPT_DEFBASE 0x5009 /* searchbase */
/* OpenLDAP TLS options */
#define LDAP_OPT_X_TLS 0x6000
* (char **) outvalue = ldap_url_list2urls(lo->ldo_defludp);
return LDAP_OPT_SUCCESS;
+ case LDAP_OPT_DEFBASE:
+ if( lo->ldo_defbase == NULL ) {
+ * (char **) outvalue = NULL;
+ } else {
+ * (char **) outvalue = LDAP_STRDUP(lo->ldo_defbase);
+ }
+
+ return LDAP_OPT_SUCCESS;
+
case LDAP_OPT_ERROR_NUMBER:
if(ld == NULL) {
/* bad param */
ludlist = ldap_url_duplist(
ldap_int_global_options.ldo_defludp);
if (ludlist == NULL)
- rc = LDAP_NO_MEMORY;
+ rc = LDAP_URL_ERR_MEM;
}
switch (rc) {
break;
}
- if (rc == LDAP_OPT_SUCCESS) {
+ if (rc == LDAP_SUCCESS) {
if (lo->ldo_defludp != NULL)
ldap_free_urllist(lo->ldo_defludp);
lo->ldo_defludp = ludlist;
return rc;
}
+ case LDAP_OPT_DEFBASE: {
+ const char *newbase = (const char *) invalue;
+ char *defbase = NULL;
+
+ if ( newbase != NULL ) {
+ defbase = LDAP_STRDUP( newbase );
+ if ( defbase == NULL ) return LDAP_NO_MEMORY;
+
+ } else if ( ld != NULL ) {
+ defbase = LDAP_STRDUP( ldap_int_global_options.ldo_defbase );
+ if ( defbase == NULL ) return LDAP_NO_MEMORY;
+ }
+
+ if ( lo->ldo_defbase != NULL )
+ LDAP_FREE( lo->ldo_defbase );
+ lo->ldo_defbase = defbase;
+ } return LDAP_OPT_SUCCESS;
+
case LDAP_OPT_ERROR_STRING: {
const char *err = (const char *) invalue;