*ep = e;
} else {
- char **values = NULL;
+ LDAPRDN *values = NULL;
+ const char *text = NULL;
unsigned long connid;
/* create exactly the required entry */
-#if 0
- struct berval rdn;
-
- /*
- * FIXME: we can pass the entire DN
- * only if rdn_attrs does not complain.
- */
- if ( dnExtractRdn( ndn, &rdn ) != LDAP_SUCCESS ) {
- return( -1 );
- }
- if ( rdn_attrs( rdn.bv_val, NULL, &values ) != LDAP_SUCCESS ) {
- free( rdn.bv_val );
+ if ( ldap_str2rdn( ndn->bv_val, &values, &text, LDAP_DN_FORMAT_LDAP ) ) {
return( -1 );
}
- free( rdn.bv_val );
-#else
- if ( rdn_attrs( ndn->bv_val, NULL, &values ) != LDAP_SUCCESS ) {
- return( -1 );
- }
-#endif
assert( values );
- assert( values[ 0 ] );
+ assert( values[ 0 ][ 0 ] );
- connid = atol( values[ 0 ] );
+ connid = atol( values[ 0 ][ 0 ]->la_value.bv_val );
- ldap_value_free( values );
+ ldap_rdnfree( values );
for ( c = connection_first( &connindex );
c != NULL;
static Entry *pw2entry(
Backend *be,
- struct passwd *pw,
- char *rdn);
+ struct passwd *pw);
int
passwd_back_search(
int sent = 0;
int err = LDAP_SUCCESS;
- char *rdn = NULL;
+ LDAPRDN *rdn = NULL;
char *parent = NULL;
char *matched = NULL;
char *user = NULL;
matched = (char *) base;
if( scope != LDAP_SCOPE_ONELEVEL ) {
- char *type;
+ const char *text;
AttributeDescription *desc = NULL;
/* Create an entry corresponding to the base DN */
/* Use the first attribute of the DN
* as an attribute within the entry itself.
*/
- rdn = dn_rdn(NULL, base);
-
- if( rdn == NULL || (s = strchr(rdn, '=')) == NULL ) {
+ if( ldap_str2rdn( base->bv_val, &rdn, &text,
+ LDAP_DN_FORMAT_LDAP ) ) {
err = LDAP_INVALID_DN_SYNTAX;
- free(rdn);
goto done;
}
- val.bv_val = rdn_attr_value(rdn);
- val.bv_len = strlen( val.bv_val );
-
- type = rdn_attr_type(rdn);
-
- {
- int rc;
- const char *text;
- rc = slap_str2ad( type, &desc, &text );
-
- if( rc != LDAP_SUCCESS ) {
- err = LDAP_NO_SUCH_OBJECT;
- free(rdn);
- goto done;
- }
+ if( slap_bv2ad( &rdn[0][0]->la_attr, &desc, &text )) {
+ err = LDAP_NO_SUCH_OBJECT;
+ ldap_rdnfree(rdn);
+ goto done;
}
+ val = rdn[0][0]->la_value;
attr_merge( e, desc, vals );
- free(rdn);
+ ldap_rdnfree(rdn);
rdn = NULL;
/* Every entry needs an objectclass. We don't really
return( 0 );
}
- e = pw2entry( be, pw, NULL );
+ e = pw2entry( be, pw );
if ( test_filter( be, conn, op, e, filter ) == LDAP_COMPARE_TRUE ) {
/* check size limit */
}
} else {
+ const char *text = NULL;
+
parent = dn_parent( be, nbase->bv_val );
/* This backend is only one layer deep. Don't answer requests for
goto done;
}
- rdn = dn_rdn( NULL, base );
-
- if ( (user = rdn_attr_value(rdn)) == NULL) {
+ if ( ldap_str2rdn( base->bv_val, &rdn, &text, LDAP_DN_FORMAT_LDAP )) {
err = LDAP_OPERATIONS_ERROR;
goto done;
}
- if ( (pw = getpwnam( user )) == NULL ) {
+ if ( (pw = getpwnam( rdn[0][0]->la_value.bv_val )) == NULL ) {
matched = parent;
err = LDAP_NO_SUCH_OBJECT;
goto done;
}
- e = pw2entry( be, pw, rdn );
+ e = pw2entry( be, pw );
if ( test_filter( be, conn, op, e, filter ) == LDAP_COMPARE_TRUE ) {
send_search_entry( be, conn, op,
err, err == LDAP_NO_SUCH_OBJECT ? matched : NULL, NULL,
NULL, NULL );
- if( rdn != NULL ) free( rdn );
- if( user != NULL ) free( user );
+ if( rdn != NULL ) ldap_rdnfree( rdn );
return( 0 );
}
static Entry *
-pw2entry( Backend *be, struct passwd *pw, char *rdn )
+pw2entry( Backend *be, struct passwd *pw )
{
size_t pwlen;
Entry *e;