1
/* bind.cpp - ndb backend bind routine */
2
/* $OpenLDAP: pkg/ldap/servers/slapd/back-ndb/bind.cpp,v 1.3.2.2 2009/01/22 00:01:09 kurt Exp $ */
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5
* Copyright 2008-2009 The OpenLDAP Foundation.
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted only as authorized by the OpenLDAP
12
* A copy of this license is available in the file LICENSE in the
13
* top-level directory of the distribution or, alternatively, at
14
* <http://www.OpenLDAP.org/license.html>.
17
* This work was initially developed by Howard Chu for inclusion
18
* in OpenLDAP Software. This work was sponsored by MySQL.
24
#include <ac/string.h>
25
#include <ac/unistd.h>
30
ndb_back_bind( Operation *op, SlapReply *rs )
32
struct ndb_info *ni = (struct ndb_info *) op->o_bd->be_private;
36
AttributeDescription *password = slap_schema.si_ad_userPassword;
40
Debug( LDAP_DEBUG_ARGS,
41
"==> " LDAP_XSTRING(ndb_back_bind) ": dn: %s\n",
42
op->o_req_dn.bv_val, 0, 0);
44
/* allow noauth binds */
45
switch ( be_rootdn_bind( op, NULL ) ) {
46
case SLAP_CB_CONTINUE:
53
/* Get our NDB handle */
54
rs->sr_err = ndb_thread_handle( op, &NA.ndb );
56
e.e_name = op->o_req_dn;
57
e.e_nname = op->o_req_ndn;
61
NA.txn = NA.ndb->startTransaction();
64
Debug( LDAP_DEBUG_TRACE,
65
LDAP_XSTRING(ndb_back_bind) ": startTransaction failed: %s (%d)\n",
66
NA.ndb->getNdbError().message, NA.ndb->getNdbError().code, 0 );
67
rs->sr_err = LDAP_OTHER;
68
rs->sr_text = "internal error";
78
rs->sr_err = ndb_entry_get_info( op, &NA, 0, NULL );
83
case LDAP_NO_SUCH_OBJECT:
84
rs->sr_err = LDAP_INVALID_CREDENTIALS;
87
rs->sr_text = "ldap_server_busy";
90
case DB_LOCK_DEADLOCK:
91
case DB_LOCK_NOTGRANTED:
95
rs->sr_err = LDAP_OTHER;
96
rs->sr_text = "internal error";
100
rs->sr_err = ndb_entry_get_data( op, &NA, 0 );
101
ber_bvarray_free_x( NA.ocs, op->o_tmpmemctx );
102
ber_dupbv( &op->oq_bind.rb_edn, &e.e_name );
104
/* check for deleted */
105
if ( is_entry_subentry( &e ) ) {
106
/* entry is an subentry, don't allow bind */
107
Debug( LDAP_DEBUG_TRACE, "entry is subentry\n", 0,
109
rs->sr_err = LDAP_INVALID_CREDENTIALS;
113
if ( is_entry_alias( &e ) ) {
114
/* entry is an alias, don't allow bind */
115
Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 );
116
rs->sr_err = LDAP_INVALID_CREDENTIALS;
120
if ( is_entry_referral( &e ) ) {
121
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
123
rs->sr_err = LDAP_INVALID_CREDENTIALS;
127
switch ( op->oq_bind.rb_method ) {
128
case LDAP_AUTH_SIMPLE:
129
a = attr_find( e.e_attrs, password );
131
rs->sr_err = LDAP_INVALID_CREDENTIALS;
135
if ( slap_passwd_check( op, &e, a, &op->oq_bind.rb_cred,
136
&rs->sr_text ) != 0 )
138
/* failure; stop front end from sending result */
139
rs->sr_err = LDAP_INVALID_CREDENTIALS;
147
assert( 0 ); /* should not be reachable */
148
rs->sr_err = LDAP_STRONG_AUTH_NOT_SUPPORTED;
149
rs->sr_text = "authentication method not supported";
155
attrs_free( e.e_attrs );
159
send_ldap_result( op, rs );
161
/* front end will send result on success (rs->sr_err==0) */