mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-05 13:40:08 +08:00
Fix attrs handling
This commit is contained in:
parent
e78a0930c8
commit
d00fe773ae
@ -112,7 +112,7 @@ ldap_back_map_filter(
|
||||
char **
|
||||
ldap_back_map_attrs(
|
||||
struct ldapmap *at_map,
|
||||
char **a,
|
||||
struct berval **a,
|
||||
int remap
|
||||
);
|
||||
|
||||
|
@ -117,6 +117,7 @@ ldap_back_db_config(
|
||||
char *dn, *massaged_dn;
|
||||
#endif /* ENABLE_REWRITE */
|
||||
BackendDB *tmp_be;
|
||||
struct berval bdn, *ndn = NULL;
|
||||
|
||||
/*
|
||||
* syntax:
|
||||
@ -137,7 +138,16 @@ ldap_back_db_config(
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
tmp_be = select_backend( argv[1], 0, 0 );
|
||||
bdn.bv_val = argv[1];
|
||||
bdn.bv_len = strlen(bdn.bv_val);
|
||||
if ( dnNormalize( NULL, &bdn, &ndn ) != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
|
||||
fname, lineno, bdn.bv_val );
|
||||
return( 1 );
|
||||
}
|
||||
tmp_be = select_backend( ndn, 0, 0 );
|
||||
ber_bvfree( ndn );
|
||||
ndn = NULL;
|
||||
if ( tmp_be != NULL && tmp_be != be ) {
|
||||
fprintf( stderr, "%s: line %d: suffix already in use"
|
||||
" by another backend in"
|
||||
@ -147,7 +157,15 @@ ldap_back_db_config(
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
tmp_be = select_backend( argv[2], 0, 0 );
|
||||
bdn.bv_val = argv[2];
|
||||
bdn.bv_len = strlen(bdn.bv_val);
|
||||
if ( dnNormalize( NULL, &bdn, &ndn ) != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
|
||||
fname, lineno, bdn.bv_val );
|
||||
return( 1 );
|
||||
}
|
||||
tmp_be = select_backend( ndn, 0, 0 );
|
||||
ber_bvfree( ndn );
|
||||
if ( tmp_be != NULL ) {
|
||||
fprintf( stderr, "%s: line %d: massaged suffix"
|
||||
" already in use by another backend in"
|
||||
@ -413,12 +431,12 @@ ldap_back_map_filter(
|
||||
char **
|
||||
ldap_back_map_attrs(
|
||||
struct ldapmap *at_map,
|
||||
char **a,
|
||||
struct berval **a,
|
||||
int remap
|
||||
)
|
||||
{
|
||||
int i, j, count;
|
||||
char **na, *mapped;
|
||||
char *mapped, **na;
|
||||
|
||||
if (a == NULL)
|
||||
return(NULL);
|
||||
@ -432,13 +450,8 @@ ldap_back_map_attrs(
|
||||
return(NULL);
|
||||
|
||||
for (i = 0, j = 0; i < count; i++) {
|
||||
mapped = ldap_back_map(at_map, a[i], remap);
|
||||
mapped = ldap_back_map(at_map, a[i]->bv_val, remap);
|
||||
if (mapped != NULL) {
|
||||
mapped = ch_strdup(mapped);
|
||||
if (mapped == NULL) {
|
||||
charray_free(na);
|
||||
return(NULL);
|
||||
}
|
||||
na[j] = mapped;
|
||||
j++;
|
||||
}
|
||||
|
@ -221,8 +221,13 @@ ldap_back_search(
|
||||
}
|
||||
|
||||
mapped_attrs = ldap_back_map_attrs(&li->at_map, attrs, 0);
|
||||
if ( mapped_attrs == NULL ) {
|
||||
mapped_attrs = attrs;
|
||||
if ( mapped_attrs == NULL && attrs) {
|
||||
for (count=0; attrs[count]; count++);
|
||||
mapped_attrs = ch_malloc( (count+1) * sizeof(char *));
|
||||
for (count=0; attrs[count]; count++) {
|
||||
mapped_attrs[count] = attrs[count]->bv_val;
|
||||
}
|
||||
mapped_attrs[count] = NULL;
|
||||
}
|
||||
|
||||
if ((msgid = ldap_search(lc->ld, mbase, scope, mapped_filter, mapped_attrs,
|
||||
@ -330,8 +335,8 @@ finish:;
|
||||
if ( err ) {
|
||||
free( err );
|
||||
}
|
||||
if ( mapped_attrs != attrs ) {
|
||||
charray_free( mapped_attrs );
|
||||
if ( mapped_attrs ) {
|
||||
free( mapped_attrs );
|
||||
}
|
||||
#ifdef ENABLE_REWRITE
|
||||
if ( mapped_filter != mfilter ) {
|
||||
|
@ -45,11 +45,14 @@ tcl_back_search (
|
||||
return (-1);
|
||||
}
|
||||
|
||||
for (i = 0; attrs != NULL && attrs[i] != NULL; i++)
|
||||
charray_add(&sattrs, attrs[i]->bv_val);
|
||||
for (i = 0; attrs != NULL && attrs[i] != NULL; i++);
|
||||
if (i > 0) {
|
||||
sattrs = ch_malloc( (i+1) * sizeof(char *));
|
||||
for (i = 0; attrs[i]; i++)
|
||||
sattrs[i] = attrs[i]->bv_val;
|
||||
sattrs[i] = NULL;
|
||||
attrs_tcl = Tcl_Merge (i, sattrs);
|
||||
charray_free(sattrs);
|
||||
free(sattrs);
|
||||
}
|
||||
|
||||
for (i = 0; be->be_suffix[i] != NULL; i++);
|
||||
|
Loading…
Reference in New Issue
Block a user