mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
normalize values only if required
This commit is contained in:
parent
19dc49180d
commit
172e93bfc9
@ -158,9 +158,6 @@ extern int suffix_massage_config( struct rewrite_info *info,
|
|||||||
extern int ldap_dnattr_rewrite( struct rewrite_info *rwinfo, BerVarray a_vals, void *cookie );
|
extern int ldap_dnattr_rewrite( struct rewrite_info *rwinfo, BerVarray a_vals, void *cookie );
|
||||||
#endif /* ENABLE_REWRITE */
|
#endif /* ENABLE_REWRITE */
|
||||||
|
|
||||||
int ldap_build_entry( Operation *op, LDAPMessage *e, Entry *ent,
|
|
||||||
struct berval *bdn, int private );
|
|
||||||
|
|
||||||
LDAP_END_DECL
|
LDAP_END_DECL
|
||||||
|
|
||||||
#endif /* SLAPD_LDAP_H */
|
#endif /* SLAPD_LDAP_H */
|
||||||
|
@ -50,6 +50,12 @@
|
|||||||
|
|
||||||
#include "lutil.h"
|
#include "lutil.h"
|
||||||
|
|
||||||
|
static int
|
||||||
|
ldap_build_entry( Operation *op, LDAPMessage *e, Entry *ent,
|
||||||
|
struct berval *bdn, int flags );
|
||||||
|
#define LDAP_BUILD_ENTRY_PRIVATE 0x01
|
||||||
|
#define LDAP_BUILD_ENTRY_NORMALIZE 0x02
|
||||||
|
|
||||||
static struct berval dummy = { 0, NULL };
|
static struct berval dummy = { 0, NULL };
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -234,7 +240,8 @@ fail:;
|
|||||||
Entry ent;
|
Entry ent;
|
||||||
struct berval bdn;
|
struct berval bdn;
|
||||||
e = ldap_first_entry(lc->ld,res);
|
e = ldap_first_entry(lc->ld,res);
|
||||||
if ( ldap_build_entry(op, e, &ent, &bdn, 1) == LDAP_SUCCESS ) {
|
if ( ldap_build_entry(op, e, &ent, &bdn,
|
||||||
|
LDAP_BUILD_ENTRY_PRIVATE) == LDAP_SUCCESS ) {
|
||||||
Attribute *a;
|
Attribute *a;
|
||||||
rs->sr_entry = &ent;
|
rs->sr_entry = &ent;
|
||||||
rs->sr_attrs = op->oq_search.rs_attrs;
|
rs->sr_attrs = op->oq_search.rs_attrs;
|
||||||
@ -379,13 +386,13 @@ finish:;
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ldap_build_entry(
|
ldap_build_entry(
|
||||||
Operation *op,
|
Operation *op,
|
||||||
LDAPMessage *e,
|
LDAPMessage *e,
|
||||||
Entry *ent,
|
Entry *ent,
|
||||||
struct berval *bdn,
|
struct berval *bdn,
|
||||||
int private
|
int flags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
|
struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
|
||||||
@ -395,6 +402,10 @@ ldap_build_entry(
|
|||||||
struct berval *bv;
|
struct berval *bv;
|
||||||
const char *text;
|
const char *text;
|
||||||
int last;
|
int last;
|
||||||
|
int private = flags & LDAP_BUILD_ENTRY_PRIVATE;
|
||||||
|
#ifdef SLAP_NVALUES
|
||||||
|
int normalize = flags & LDAP_BUILD_ENTRY_NORMALIZE;
|
||||||
|
#endif /* SLAP_NVALUES */
|
||||||
|
|
||||||
/* safe assumptions ... */
|
/* safe assumptions ... */
|
||||||
assert( ent );
|
assert( ent );
|
||||||
@ -618,22 +629,26 @@ ldap_build_entry(
|
|||||||
next_attr:;
|
next_attr:;
|
||||||
|
|
||||||
#ifdef SLAP_NVALUES
|
#ifdef SLAP_NVALUES
|
||||||
if ( last && attr->a_desc->ad_type->sat_equality &&
|
if ( normalize ) {
|
||||||
attr->a_desc->ad_type->sat_equality->smr_normalize ) {
|
if ( last && attr->a_desc->ad_type->sat_equality &&
|
||||||
int i;
|
attr->a_desc->ad_type->sat_equality->smr_normalize ) {
|
||||||
|
int i;
|
||||||
|
|
||||||
attr->a_nvals = ch_malloc((last+1)*sizeof(struct berval));
|
attr->a_nvals = ch_malloc((last+1)*sizeof(struct berval));
|
||||||
for (i=0; i<last; i++) {
|
for (i=0; i<last; i++) {
|
||||||
attr->a_desc->ad_type->sat_equality->smr_normalize(
|
attr->a_desc->ad_type->sat_equality->smr_normalize(
|
||||||
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
|
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
|
||||||
attr->a_desc->ad_type->sat_syntax,
|
attr->a_desc->ad_type->sat_syntax,
|
||||||
attr->a_desc->ad_type->sat_equality,
|
attr->a_desc->ad_type->sat_equality,
|
||||||
&attr->a_vals[i], &attr->a_nvals[i] );
|
&attr->a_vals[i], &attr->a_nvals[i] );
|
||||||
|
}
|
||||||
|
attr->a_nvals[i].bv_val = NULL;
|
||||||
|
attr->a_nvals[i].bv_len = 0;
|
||||||
|
} else {
|
||||||
|
attr->a_nvals = attr->a_vals;
|
||||||
}
|
}
|
||||||
attr->a_nvals[i].bv_val = NULL;
|
|
||||||
attr->a_nvals[i].bv_len = 0;
|
|
||||||
} else {
|
} else {
|
||||||
attr->a_nvals = attr->a_vals;
|
attr->a_nvals = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*attrp = attr;
|
*attrp = attr;
|
||||||
@ -753,7 +768,7 @@ ldap_back_entry_get(
|
|||||||
|
|
||||||
*ent = ch_calloc(1,sizeof(Entry));
|
*ent = ch_calloc(1,sizeof(Entry));
|
||||||
|
|
||||||
rc = ldap_build_entry(op, e, *ent, &bdn, 0);
|
rc = ldap_build_entry(op, e, *ent, &bdn, LDAP_BUILD_ENTRY_NORMALIZE);
|
||||||
|
|
||||||
if (rc != LDAP_SUCCESS) {
|
if (rc != LDAP_SUCCESS) {
|
||||||
ch_free(*ent);
|
ch_free(*ent);
|
||||||
|
Loading…
Reference in New Issue
Block a user