mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-17 14:00:30 +08:00
print the correct search base when taken from ldaprc (ITS#4504)
This commit is contained in:
parent
02b3af0900
commit
8242166888
@ -899,10 +899,16 @@ getNextPage:
|
||||
}
|
||||
|
||||
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"
|
||||
@ -943,6 +949,10 @@ getNextPage:
|
||||
}
|
||||
|
||||
printf( _("\n#\n\n") );
|
||||
|
||||
if ( realbase && realbase != base ) {
|
||||
ldap_memfree( realbase );
|
||||
}
|
||||
}
|
||||
|
||||
if ( infile == NULL ) {
|
||||
|
@ -120,6 +120,7 @@ LDAP_BEGIN_DECL
|
||||
#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
|
||||
|
@ -230,6 +230,15 @@ ldap_get_option(
|
||||
* (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 */
|
||||
@ -509,7 +518,7 @@ ldap_set_option(
|
||||
ludlist = ldap_url_duplist(
|
||||
ldap_int_global_options.ldo_defludp);
|
||||
if (ludlist == NULL)
|
||||
rc = LDAP_NO_MEMORY;
|
||||
rc = LDAP_URL_ERR_MEM;
|
||||
}
|
||||
|
||||
switch (rc) {
|
||||
@ -534,7 +543,7 @@ ldap_set_option(
|
||||
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;
|
||||
@ -542,6 +551,24 @@ ldap_set_option(
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user