1 /* bind.c - ldbm backend bind and unbind routines */
10 #include <ac/unistd.h>
13 #include "back-ldbm.h"
14 #include "proto-back-ldbm.h"
19 extern int krbv4_ldap_auth();
22 pthread_mutex_t crypt_mutex;
34 for ( i = 0; vals[i] != NULL; i++ ) {
35 if ( syntax != SYNTAX_BIN ) {
38 pthread_mutex_lock( &crypt_mutex );
40 result = lutil_passwd(
42 (char*) vals[i]->bv_val);
44 pthread_mutex_unlock( &crypt_mutex );
49 if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {
68 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
74 char krbname[MAX_K_NAME_SZ + 1];
78 Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
80 /* get entry with reader lock */
81 if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
82 /* allow noauth binds */
83 if ( method == LDAP_AUTH_SIMPLE && cred->bv_len == 0 ) {
85 * bind successful, but return 1 so we don't
86 * authorize based on noauth credentials
88 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
90 } else if ( be_isroot_pw( be, dn, cred ) ) {
91 /* front end will send result */
94 send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, NULL );
97 if ( matched != NULL ) {
103 /* check for deleted */
106 case LDAP_AUTH_SIMPLE:
107 if ( cred->bv_len == 0 ) {
108 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
110 /* stop front end from sending result */
113 } else if ( be_isroot_pw( be, dn, cred ) ) {
114 /* front end will send result */
119 if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) {
120 if ( be_isroot_pw( be, dn, cred ) ) {
121 /* front end will send result */
125 send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
132 if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 )
134 if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 )
137 if ( be_isroot_pw( be, dn, cred ) ) {
138 /* front end will send result */
142 send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
151 case LDAP_AUTH_KRBV41:
152 if ( krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) {
153 send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
158 sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
159 : "", ad.pinst, ad.prealm );
160 if ( (a = attr_find( e->e_attrs, "krbname" )) == NULL ) {
162 * no krbName values present: check against DN
164 if ( strcasecmp( dn, krbname ) == 0 ) {
165 rc = 0; /* XXX wild ass guess */
168 send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
172 } else { /* look for krbName match */
173 struct berval krbval;
175 krbval.bv_val = krbname;
176 krbval.bv_len = strlen( krbname );
178 if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) {
179 send_ldap_result( conn, op,
180 LDAP_INVALID_CREDENTIALS, NULL, NULL );
188 case LDAP_AUTH_KRBV42:
189 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
190 /* stop front end from sending result */
196 send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED,
197 NULL, "auth method not supported" );
203 /* free entry and reader lock */
204 cache_return_entry_r( &li->li_cache, e );
206 /* front end with send result on success (rc==0) */