X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fbind.c;h=9739773aea7470bf4e1e9f699df50363b598a1aa;hb=82c1b0d1f0a27e374961c910473f549878e81e24;hp=0158a9cff254b94eb8c2e221be1023ea4205c6fa;hpb=377bccbc6c0c39bb64240562dbf18d7372122900;p=openldap
diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c
index 0158a9cff2..9739773aea 100644
--- a/servers/slapd/back-bdb/bind.c
+++ b/servers/slapd/back-bdb/bind.c
@@ -1,8 +1,17 @@
/* bind.c - bdb backend bind routine */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 2000-2004 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
#include "portable.h"
@@ -35,9 +44,11 @@ bdb_bind( Operation *op, SlapReply *rs )
DB_LOCK lock;
#ifdef NEW_LOGGING
- LDAP_LOG ( OPERATION, ARGS, "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0 );
+ LDAP_LOG ( OPERATION, ARGS,
+ "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0 );
#else
- Debug( LDAP_DEBUG_ARGS, "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0);
+ Debug( LDAP_DEBUG_ARGS,
+ "==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0);
#endif
/* allow noauth binds */
@@ -59,8 +70,8 @@ bdb_bind( Operation *op, SlapReply *rs )
dn2entry_retry:
/* get entry with reader lock */
- rs->sr_err = bdb_dn2entry( op->o_bd, NULL, &op->o_req_ndn, &ei, 1,
- locker, &lock, op->o_tmpmemctx );
+ rs->sr_err = bdb_dn2entry( op, NULL, &op->o_req_ndn, &ei, 1,
+ locker, &lock );
switch(rs->sr_err) {
case DB_NOTFOUND:
@@ -82,30 +93,13 @@ dn2entry_retry:
e = ei->bei_e;
if ( rs->sr_err == DB_NOTFOUND ) {
if( e != NULL ) {
- rs->sr_ref = is_entry_referral( e )
- ? get_entry_referrals( op, e )
- : NULL;
- if (rs->sr_ref)
- rs->sr_matched = ch_strdup( e->e_name.bv_val );
-
- bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb->bi_dbenv,
+ &bdb->bi_cache, e, &lock );
e = NULL;
- } else {
- rs->sr_ref = referral_rewrite( default_referral,
- NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
}
- if ( rs->sr_ref != NULL ) {
- rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
- free( (char *)rs->sr_matched );
- ber_bvarray_free( rs->sr_ref );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
- } else {
- rs->sr_err = LDAP_INVALID_CREDENTIALS;
- send_ldap_result( op, rs );
- }
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
+ send_ldap_result( op, rs );
LOCK_ID_FREE(bdb->bi_dbenv, locker);
@@ -125,10 +119,7 @@ dn2entry_retry:
Debug( LDAP_DEBUG_TRACE, "entry is subentry\n", 0,
0, 0 );
#endif
-
rs->sr_err = LDAP_INVALID_CREDENTIALS;
- send_ldap_result( op );
-
goto done;
}
#endif
@@ -137,22 +128,23 @@ dn2entry_retry:
if ( is_entry_alias( e ) ) {
/* entry is an alias, don't allow bind */
#ifdef NEW_LOGGING
- LDAP_LOG ( OPERATION, DETAIL1, "bdb_bind: entry is alias\n", 0, 0, 0 );
+ LDAP_LOG ( OPERATION, DETAIL1,
+ "bdb_bind: entry is alias\n", 0, 0, 0 );
#else
- Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0,
- 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 );
#endif
- send_ldap_error( op, rs, LDAP_ALIAS_PROBLEM, "entry is alias");
-
+#if 1
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
+#else
+ rs->sr_err = LDAP_ALIAS_PROBLEM;
+ rs->sr_text = "entry is alias";
+#endif
goto done;
}
#endif
if ( is_entry_referral( e ) ) {
- /* entry is a referral, don't allow bind */
- rs->sr_ref = get_entry_referrals( op, e );
-
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, DETAIL1,
"bdb_bind: entry is referral\n", 0, 0, 0 );
@@ -160,19 +152,7 @@ dn2entry_retry:
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
0, 0 );
#endif
-
- if( rs->sr_ref != NULL ) {
- rs->sr_err = LDAP_REFERRAL;
- rs->sr_matched = e->e_name.bv_val;
- send_ldap_result( op, rs );
- ber_bvarray_free( rs->sr_ref );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
- } else {
- rs->sr_err = LDAP_INVALID_CREDENTIALS;
- send_ldap_result( op, rs );
- }
-
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
goto done;
}
@@ -181,20 +161,27 @@ dn2entry_retry:
rs->sr_err = access_allowed( op, e,
password, NULL, ACL_AUTH, NULL );
if ( ! rs->sr_err ) {
+#if 1
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
+#else
rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
- send_ldap_result( op, rs );
+#endif
goto done;
}
if ( (a = attr_find( e->e_attrs, password )) == NULL ) {
+#if 1
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
+#else
rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
- send_ldap_result( op, rs );
+#endif
goto done;
}
- if ( slap_passwd_check( op->o_conn, a, &op->oq_bind.rb_cred ) != 0 ) {
+ if ( slap_passwd_check( op->o_conn,
+ a, &op->oq_bind.rb_cred, &rs->sr_text ) != 0 )
+ {
rs->sr_err = LDAP_INVALID_CREDENTIALS;
- send_ldap_result( op, rs );
goto done;
}
@@ -203,9 +190,10 @@ dn2entry_retry:
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
case LDAP_AUTH_KRBV41:
- if ( krbv4_ldap_auth( op->o_bd, &op->oq_bind.rb_cred, &ad ) != LDAP_SUCCESS ) {
+ if ( krbv4_ldap_auth( op->o_bd, &op->oq_bind.rb_cred, &ad )
+ != LDAP_SUCCESS )
+ {
rs->sr_err = LDAP_INVALID_CREDENTIALS,
- send_ldap_result( op );
goto done;
}
@@ -213,12 +201,11 @@ dn2entry_retry:
krbattr, NULL, ACL_AUTH, NULL );
if ( ! rs->sr_err ) {
rs->sr_err = LDAP_INSUFFICIENT_ACCESS,
- send_ldap_result( op );
goto done;
}
- krbval.bv_len = sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
- : "", ad.pinst, ad.prealm );
+ krbval.bv_len = sprintf( krbname, "%s%s%s@%s", ad.pname,
+ *ad.pinst ? "." : "", ad.pinst, ad.prealm );
if ( (a = attr_find( e->e_attrs, krbattr )) == NULL ) {
/*
@@ -229,7 +216,6 @@ dn2entry_retry:
break;
}
rs->sr_err = LDAP_INAPPROPRIATE_AUTH,
- send_ldap_result( op );
goto done;
} else { /* look for krbname match */
@@ -237,23 +223,17 @@ dn2entry_retry:
if ( value_find( a->a_desc, a->a_vals, &krbval ) != 0 ) {
rs->sr_err = LDAP_INVALID_CREDENTIALS;
- send_ldap_result( op );
goto done;
}
}
rs->sr_err = 0;
break;
-
- case LDAP_AUTH_KRBV42:
- send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
- "Kerberos bind step 2 not supported" );
- goto done;
#endif
default:
- send_ldap_error( op, rs, LDAP_STRONG_AUTH_NOT_SUPPORTED,
- "authentication method not supported" );
- goto done;
+ assert( 0 ); /* should not be unreachable */
+ rs->sr_err = LDAP_STRONG_AUTH_NOT_SUPPORTED;
+ rs->sr_text = "authentication method not supported";
}
done:
@@ -264,6 +244,13 @@ done:
LOCK_ID_FREE(bdb->bi_dbenv, locker);
+ if ( rs->sr_err ) {
+ send_ldap_result( op, rs );
+ if ( rs->sr_ref ) {
+ ber_bvarray_free( rs->sr_ref );
+ rs->sr_ref = NULL;
+ }
+ }
/* front end will send result on success (rs->sr_err==0) */
return rs->sr_err;
}