1 /* OpenLDAP WiredTiger backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2002-2017 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 developed by HAMANO Tsukasa <hamano@osstech.co.jp>
18 * based on back-bdb for inclusion in OpenLDAP Software.
19 * WiredTiger is a product of MongoDB Inc.
29 wt_bind( Operation *op, SlapReply *rs )
31 struct wt_info *wi = (struct wt_info *) op->o_bd->be_private;
37 AttributeDescription *password = slap_schema.si_ad_userPassword;
39 Debug( LDAP_DEBUG_ARGS,
40 "==> " LDAP_XSTRING(wt_bind) ": dn: %s\n",
41 op->o_req_dn.bv_val, 0, 0);
43 /* allow noauth binds */
44 switch ( be_rootdn_bind( op, NULL ) ) {
46 /* frontend will send result */
47 return rs->sr_err = LDAP_SUCCESS;
50 /* give the database a chance */
51 /* NOTE: this behavior departs from that of other backends,
52 * since the others, in case of password checking failure
53 * do not give the database a chance. If an entry with
54 * rootdn's name does not exist in the database the result
55 * will be the same. See ITS#4962 for discussion. */
59 wc = wt_ctx_get(op, wi);
61 Debug( LDAP_DEBUG_ANY,
63 ": wt_ctx_get failed\n",
65 rs->sr_err = LDAP_OTHER;
66 rs->sr_text = "internal error";
67 send_ldap_result( op, rs );
72 rc = wt_dn2entry(op->o_bd, wc, &op->o_req_ndn, &e);
77 rs->sr_err = LDAP_INVALID_CREDENTIALS;
78 send_ldap_result( op, rs );
81 rs->sr_err = LDAP_OTHER;
82 rs->sr_text = "internal error";
83 send_ldap_result( op, rs );
87 ber_dupbv( &op->oq_bind.rb_edn, &e->e_name );
89 /* check for deleted */
90 if ( is_entry_subentry( e ) ) {
91 /* entry is an subentry, don't allow bind */
92 Debug( LDAP_DEBUG_TRACE, "entry is subentry\n", 0,
94 rs->sr_err = LDAP_INVALID_CREDENTIALS;
98 if ( is_entry_alias( e ) ) {
99 /* entry is an alias, don't allow bind */
100 Debug( LDAP_DEBUG_TRACE, "entry is alias\n", 0, 0, 0 );
101 rs->sr_err = LDAP_INVALID_CREDENTIALS;
105 if ( is_entry_referral( e ) ) {
106 Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
108 rs->sr_err = LDAP_INVALID_CREDENTIALS;
112 switch ( op->oq_bind.rb_method ) {
113 case LDAP_AUTH_SIMPLE:
114 a = attr_find( e->e_attrs, password );
116 rs->sr_err = LDAP_INVALID_CREDENTIALS;
120 if ( slap_passwd_check( op, e, a, &op->oq_bind.rb_cred,
121 &rs->sr_text ) != 0 )
123 /* failure; stop front end from sending result */
124 rs->sr_err = LDAP_INVALID_CREDENTIALS;
131 rs->sr_err = LDAP_STRONG_AUTH_NOT_SUPPORTED;
132 rs->sr_text = "authentication method not supported";
141 send_ldap_result( op, rs );
143 ber_bvarray_free( rs->sr_ref );
152 * indent-tabs-mode: t