Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char** edn
+ struct berval *edn
)
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
AttributeDescription *password = slap_schema.si_ad_userPassword;
- Debug( LDAP_DEBUG_ARGS, "==> bdb_bind: dn: %s\n", dn, 0, 0);
-
- *edn = NULL;
+ Debug( LDAP_DEBUG_ARGS, "==> bdb_bind: dn: %s\n", dn->bv_val, 0, 0);
/* get entry */
- rc = bdb_dn2entry( be, NULL, ndn, &e, &matched, 0 );
+ rc = bdb_dn2entry( be, NULL, ndn->bv_val, &e, &matched, 0 );
switch(rc) {
case DB_NOTFOUND:
refs = is_entry_referral( matched )
? get_entry_referrals( be, conn, op, matched,
- dn, LDAP_SCOPE_DEFAULT )
+ dn->bv_val, LDAP_SCOPE_DEFAULT )
: NULL;
bdb_entry_return( be, matched );
} else {
refs = referral_rewrite( default_referral,
- NULL, dn, LDAP_SCOPE_DEFAULT );
+ NULL, dn->bv_val, LDAP_SCOPE_DEFAULT );
}
/* allow noauth binds */
rc = 1;
if ( method == LDAP_AUTH_SIMPLE ) {
if ( be_isroot_pw( be, conn, ndn, cred ) ) {
- *edn = ch_strdup( be_root_dn( be ) );
+ ber_dupbv( edn, be_root_dn( be ) );
rc = LDAP_SUCCESS; /* front end will send result */
} else if ( refs != NULL ) {
return rc;
}
- *edn = ch_strdup( e->e_dn );
+ ber_dupbv( edn, &e->e_name );
/* check for deleted */
if ( is_entry_referral( e ) ) {
/* entry is a referral, don't allow bind */
struct berval **refs = get_entry_referrals( be,
- conn, op, e, dn, LDAP_SCOPE_DEFAULT );
+ conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
0, 0 );
/* check for root dn/passwd */
if ( be_isroot_pw( be, conn, ndn, cred ) ) {
/* front end will send result */
- if(*edn != NULL) free( *edn );
- *edn = ch_strdup( be_root_dn( be ) );
+ if(edn->bv_val != NULL) free( edn->bv_val );
+ ber_dupbv( edn, be_root_dn( be ) );
rc = LDAP_SUCCESS;
goto done;
}
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char **edn )
+ struct berval *edn )
{
Debug( LDAP_DEBUG_TRACE, "DNSSRV: bind %s (%d)\n",
- dn == NULL ? "" : dn,
+ dn->bv_val == NULL ? "" : dn->bv_val,
method, NULL );
if( method == LDAP_AUTH_SIMPLE && cred != NULL && cred->bv_len ) {
Statslog( LDAP_DEBUG_STATS,
"conn=%ld op=%d DNSSRV BIND dn=\"%s\" provided passwd\n",
op->o_connid, op->o_opid,
- dn == NULL ? "" : dn , 0, 0 );
+ dn->bv_val == NULL ? "" : dn->bv_val , 0, 0 );
Debug( LDAP_DEBUG_TRACE,
"DNSSRV: BIND dn=\"%s\" provided cleartext password\n",
- dn == NULL ? "" : dn, 0, 0 );
+ dn->bv_val == NULL ? "" : dn->bv_val, 0, 0 );
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "you shouldn\'t send strangers your password",
} else {
Debug( LDAP_DEBUG_TRACE, "DNSSRV: BIND dn=\"%s\"\n",
- dn == NULL ? "" : dn, 0, 0 );
+ dn->bv_val == NULL ? "" : dn->bv_val, 0, 0 );
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
NULL, "anonymous bind expected",
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char **edn
+ struct berval *edn
)
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
char *mdn = NULL;
int rc = 0;
- *edn = NULL;
-
lc = ldap_back_getconn(li, conn, op);
if ( !lc ) {
return( -1 );
* Rewrite the bind dn if needed
*/
#ifdef ENABLE_REWRITE
- switch ( rewrite_session( li->rwinfo, "bindDn", dn, conn, &mdn ) ) {
+ switch ( rewrite_session( li->rwinfo, "bindDn", dn->bv_val, conn, &mdn ) ) {
case REWRITE_REGEXEC_OK:
if ( mdn == NULL ) {
- mdn = ( char * )dn;
+ mdn = ( char * )dn->bv_val;
}
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
- "[rw] bindDn: \"%s\" -> \"%s\"\n", dn, mdn ));
+ "[rw] bindDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n%s",
- dn, mdn, "" );
+ dn->bv_val, mdn, "" );
#endif /* !NEW_LOGGING */
break;
return( -1 );
}
#else /* !ENABLE_REWRITE */
- mdn = ldap_back_dn_massage( li, ch_strdup( dn ), 0 );
+ mdn = ldap_back_dn_massage( li, ch_strdup( dn->bv_val ), 0 );
#endif /* !ENABLE_REWRITE */
rc = ldap_bind_s(lc->ld, mdn, cred->bv_val, method);
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char** edn
+ struct berval *edn
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
- "ldbm_back_bind: dn: %s.\n", dn ));
+ "ldbm_back_bind: dn: %s.\n", dn->bv_val ));
#else
- Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
+ Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn->bv_val, 0, 0);
#endif
- *edn = NULL;
dn = ndn;
/* get entry with reader lock */
- if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
+ if ( (e = dn2entry_r( be, dn->bv_val, &matched )) == NULL ) {
char *matched_dn = NULL;
struct berval **refs = NULL;
refs = is_entry_referral( matched )
? get_entry_referrals( be, conn, op, matched,
- dn, LDAP_SCOPE_DEFAULT )
+ dn->bv_val, LDAP_SCOPE_DEFAULT )
: NULL;
cache_return_entry_r( &li->li_cache, matched );
} else {
refs = referral_rewrite( default_referral,
- NULL, dn, LDAP_SCOPE_DEFAULT );
+ NULL, dn->bv_val, LDAP_SCOPE_DEFAULT );
}
/* allow noauth binds */
rc = 1;
if ( method == LDAP_AUTH_SIMPLE ) {
if ( be_isroot_pw( be, conn, dn, cred ) ) {
- *edn = ch_strdup( be_root_dn( be ) );
+ ber_dupbv( edn, be_root_dn( be ) );
rc = 0; /* front end will send result */
} else if ( refs != NULL ) {
return( rc );
}
- *edn = ch_strdup( e->e_dn );
+ ber_dupbv( edn, &e->e_name );
/* check for deleted */
if ( is_entry_referral( e ) ) {
/* entry is a referral, don't allow bind */
struct berval **refs = get_entry_referrals( be,
- conn, op, e, dn, LDAP_SCOPE_DEFAULT );
+ conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT );
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
/* check for root dn/passwd */
if ( be_isroot_pw( be, conn, dn, cred ) ) {
/* front end will send result */
- if(*edn != NULL) free( *edn );
- *edn = ch_strdup( be_root_dn( be ) );
+ if(edn->bv_val != NULL) free( edn->bv_val );
+ ber_dupbv( edn, be_root_dn( be ) );
rc = 0;
goto return_results;
}
/*
* no krbname values present: check against DN
*/
- if ( strcasecmp( dn, krbname ) == 0 ) {
+ if ( strcasecmp( dn->bv_val, krbname ) == 0 ) {
rc = 0;
break;
}
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char **edn
+ struct berval *edn
)
{
struct metainfo *li = ( struct metainfo * )be->be_private;
int op_type = META_OP_ALLOW_MULTIPLE;
int err = LDAP_SUCCESS;
- char *realdn = (char *)dn;
- char *realndn = (char *)ndn;
+ char *realdn = (char *)dn->bv_val;
+ char *realndn = (char *)ndn->bv_val;
char *realcred = cred->bv_val;
int realmethod = method;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
- "meta_back_bind: dn: %s.\n", dn ));
+ "meta_back_bind: dn: %s.\n", dn->bv_val ));
#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS, "meta_back_bind: dn: %s.\n%s%s", dn, "", "" );
+ Debug( LDAP_DEBUG_ARGS, "meta_back_bind: dn: %s.\n%s%s", dn->bv_val, "", "" );
#endif /* !NEW_LOGGING */
- *edn = NULL;
-
if ( method == LDAP_AUTH_SIMPLE
&& be_isroot_pw( be, conn, ndn, cred ) ) {
isroot = 1;
- *edn = ch_strdup( be_root_dn( be ) );
+ ber_dupbv( edn, be_root_dn( be ) );
op_type = META_OP_REQUIRE_ALL;
}
- lc = meta_back_getconn( li, conn, op, op_type, ndn, NULL );
+ lc = meta_back_getconn( li, conn, op, op_type, ndn->bv_val, NULL );
if ( !lc ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_NOTICE,
"meta_back_bind: no target for dn %s.\n",
- dn ));
+ dn->bv_val ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"meta_back_bind: no target for dn %s.\n%s%s",
- dn, "", "");
+ dn->bv_val, "", "");
#endif /* !NEW_LOGGING */
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL );
* Each target is scanned ...
*/
lc->bound_target = META_BOUND_NONE;
- ndnlen = strlen( ndn );
+ ndnlen = ndn->bv_len;
for ( i = 0; i < li->ntargets; i++ ) {
int lerr;
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char** edn
+ struct berval *edn
)
{
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
- "monitor_back_bind: dn: %s.\n", dn ));
+ "monitor_back_bind: dn: %s.\n", dn->bv_val ));
#else
Debug(LDAP_DEBUG_ARGS, "==> monitor_back_bind: dn: %s\n%s%s",
- dn, "", "");
+ dn->bv_val, "", "");
#endif
if ( method == LDAP_AUTH_SIMPLE
&& be_isroot_pw( be, conn, ndn, cred ) ) {
- *edn = ch_strdup( be_root_dn( be ) );
+ ber_dupbv( edn, be_root_dn( be ) );
return( 0 );
}
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char** edn
+ struct berval *edn
)
{
int return_code;
PerlBackend *perl_back = (PerlBackend *) be->be_private;
- *edn = NULL;
-
ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
{
PUSHMARK(sp);
XPUSHs( perl_back->pb_obj_ref );
- XPUSHs(sv_2mortal(newSVpv( dn , 0)));
+ XPUSHs(sv_2mortal(newSVpv( dn->bv_val , 0)));
XPUSHs(sv_2mortal(newSVpv( cred->bv_val , cred->bv_len)));
PUTBACK;
SPAGAIN;
if (count != 1) {
- croak("Big trouble in back_search\n");
+ croak("Big trouble in back_bind\n");
}
return_code = POPi;
Backend *be,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char **edn
+ struct berval *edn
)
{
struct shellinfo *si = (struct shellinfo *) be->be_private;
FILE *rfp, *wfp;
int rc;
- *edn = NULL;
-
if ( si->si_bind == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"bind not implemented", NULL, NULL );
fprintf( wfp, "BIND\n" );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
- fprintf( wfp, "dn: %s\n", dn );
+ fprintf( wfp, "dn: %s\n", dn->bv_val );
fprintf( wfp, "method: %d\n", method );
fprintf( wfp, "credlen: %lu\n", cred->bv_len );
fprintf( wfp, "cred: %s\n", cred->bv_val ); /* XXX */
#include "entry-id.h"
int backsql_bind(BackendDB *be,Connection *conn,Operation *op,
- const char *dn,const char *ndn,int method,struct berval *cred,char** edn)
+ struct berval *dn,struct berval *ndn,int method,struct berval *cred,struct berval *edn)
{
backsql_info *bi=(backsql_info*)be->be_private;
backsql_entryID user_id,*res;
if ( be_isroot_pw( be, conn, ndn, cred ) )
{
- *edn=ch_strdup(be_root_dn(be));
+ ber_dupbv(edn, be_root_dn(be));
Debug(LDAP_DEBUG_TRACE,"<==backsql_bind() root bind\n",0,0,0);
return LDAP_SUCCESS;
}
- *edn=ch_strdup(ndn);
+ ber_dupbv(edn, ndn);
if (method == LDAP_AUTH_SIMPLE)
{
return 1;
}
- res=backsql_dn2id(bi,&user_id,dbh,ndn);
+ res=backsql_dn2id(bi,&user_id,dbh,ndn->bv_val);
if (res==NULL)
{
Debug(LDAP_DEBUG_TRACE,"backsql_bind(): could not retrieve bind dn id - no such entry\n",0,0,0);
return 1;
}
- backsql_init_search(&bsi,bi,(char*)ndn,LDAP_SCOPE_BASE,-1,-1,-1,NULL,dbh,
+ backsql_init_search(&bsi,bi,(char*)ndn->bv_val,LDAP_SCOPE_BASE,-1,-1,-1,NULL,dbh,
be,conn,op,NULL);
e=backsql_id2entry(&bsi,&user_entry,&user_id);
if (e==NULL)
Backend * be,
Connection * conn,
Operation * op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char **edn
+ struct berval *edn
)
{
char *command, *suf_tcl, *results;
int i, code, err = 0;
struct tclinfo *ti = (struct tclinfo *) be->be_private;
- *edn = NULL;
-
if (ti->ti_bind == NULL) {
send_ldap_result (conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"bind not implemented", NULL, NULL );
command = (char *) ch_malloc (strlen (ti->ti_bind) + strlen
(suf_tcl) +
- strlen (dn) + strlen (cred->bv_val) + 64);
+ dn->bv_len + cred->bv_len + 64);
sprintf (command, "%s BIND {%ld} {%s} {%s} {%d} {%lu} {%s}",
- ti->ti_bind, op->o_msgid, suf_tcl, dn, method, cred->bv_len,
+ ti->ti_bind, op->o_msgid, suf_tcl, dn->bv_val, method, cred->bv_len,
cred->bv_val);
Tcl_Free (suf_tcl);
return strcmp( be->be_update_ndn.bv_val, ndn->bv_val ) ? 0 : 1;
}
-char *
+struct berval *
be_root_dn( Backend *be )
{
- if ( !be->be_rootdn.bv_len ) {
- return( "" );
- }
-
- return be->be_rootdn.bv_val;
+ return &be->be_rootdn;
}
int
be_isroot_pw( Backend *be,
Connection *conn,
- const char *dn,
+ struct berval *ndn,
struct berval *cred )
{
int result;
- struct berval ndn;
- ndn.bv_val = (char *) dn;
- ndn.bv_len = dn ? strlen( dn ) : 0;
-
- if ( ! be_isroot( be, &ndn ) ) {
+ if ( ! be_isroot( be, ndn ) ) {
return 0;
}
BackendDB *b0,
Connection *conn,
Operation *op,
- const char *dn,
- const char *ndn,
+ struct berval *dn,
+ struct berval *ndn,
int method,
struct berval *cred,
- char **edn
+ struct berval *edn
)
{
BackendDB *be;
int rc;
- be = glue_back_select (b0, ndn);
+ be = glue_back_select (b0, ndn->bv_val);
if (be && be->be_bind) {
conn->c_authz_backend = be;
if ( be->be_bind ) {
int ret;
/* alias suffix */
- char *edn = NULL;
+ struct berval edn = { 0, NULL };
/* deref suffix alias if appropriate */
suffix_alias( be, ndn );
ret = (*be->be_bind)( be, conn, op,
- pdn->bv_val, ndn->bv_val,
- method, &cred, &edn );
+ pdn, ndn, method, &cred, &edn );
if ( ret == 0 ) {
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
- if(edn != NULL) {
- conn->c_dn.bv_val = edn;
- conn->c_dn.bv_len = strlen( edn );
+ if(edn.bv_len) {
+ conn->c_dn = edn;
} else {
conn->c_dn.bv_val = ch_strdup( pdn->bv_val );
conn->c_dn.bv_len = pdn->bv_len;
send_ldap_result( conn, op, LDAP_SUCCESS,
NULL, NULL, NULL, NULL );
- } else if (edn != NULL) {
- free( edn );
+ } else if (edn.bv_val != NULL) {
+ free( edn.bv_val );
}
} else {
LDAP_SLAPD_F (int) be_isroot LDAP_P(( Backend *be,
struct berval *ndn ));
LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Backend *be,
- Connection *conn, const char *ndn, struct berval *cred ));
+ Connection *conn, struct berval *ndn, struct berval *cred ));
LDAP_SLAPD_F (int) be_isupdate LDAP_P(( Backend *be, struct berval *ndn ));
-LDAP_SLAPD_F (char *) be_root_dn LDAP_P(( Backend *be ));
+LDAP_SLAPD_F (struct berval *) be_root_dn LDAP_P(( Backend *be ));
LDAP_SLAPD_F (int) be_entry_release_rw LDAP_P((
BackendDB *be, Connection *c, Operation *o, Entry *e, int rw ));
#define be_entry_release_r( be, c, o, e ) be_entry_release_rw( be, c, o, e, 0 )
typedef int (BI_op_bind) LDAP_P(( BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
- const char *dn, const char *ndn, int method,
- struct berval *cred, char** edn ));
+ struct berval *dn, struct berval *ndn, int method,
+ struct berval *cred, struct berval *edn ));
typedef int (BI_op_unbind) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o ));
typedef int (BI_op_search) LDAP_P((BackendDB *bd,