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();
32 for ( i = 0; vals[i] != NULL; i++ ) {
33 if ( syntax != SYNTAX_BIN ) {
37 pthread_mutex_lock( &crypt_mutex );
40 result = lutil_passwd(
42 (char*) vals[i]->bv_val);
45 pthread_mutex_unlock( &crypt_mutex );
51 if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {
70 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
76 char krbname[MAX_K_NAME_SZ + 1];
80 Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
82 /* get entry with reader lock */
83 if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
84 /* allow noauth binds */
85 if ( method == LDAP_AUTH_SIMPLE && cred->bv_len == 0 ) {
87 * bind successful, but return 1 so we don't
88 * authorize based on noauth credentials
90 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
92 } else if ( be_isroot_pw( be, dn, cred ) ) {
93 /* front end will send result */
96 send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, NULL );
99 if ( matched != NULL ) {
105 /* check for deleted */
108 case LDAP_AUTH_SIMPLE:
109 if ( cred->bv_len == 0 ) {
110 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
112 /* stop front end from sending result */
115 } else if ( be_isroot_pw( be, dn, cred ) ) {
116 /* front end will send result */
121 if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) {
122 if ( be_isroot_pw( be, dn, cred ) ) {
123 /* front end will send result */
127 send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
134 if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 )
136 if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 )
139 if ( be_isroot_pw( be, dn, cred ) ) {
140 /* front end will send result */
144 send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
153 case LDAP_AUTH_KRBV41:
154 if ( krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) {
155 send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
160 sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
161 : "", ad.pinst, ad.prealm );
162 if ( (a = attr_find( e->e_attrs, "krbname" )) == NULL ) {
164 * no krbName values present: check against DN
166 if ( strcasecmp( dn, krbname ) == 0 ) {
167 rc = 0; /* XXX wild ass guess */
170 send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
174 } else { /* look for krbName match */
175 struct berval krbval;
177 krbval.bv_val = krbname;
178 krbval.bv_len = strlen( krbname );
180 if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) {
181 send_ldap_result( conn, op,
182 LDAP_INVALID_CREDENTIALS, NULL, NULL );
190 case LDAP_AUTH_KRBV42:
191 send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
192 /* stop front end from sending result */
198 send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED,
199 NULL, "auth method not supported" );
205 /* free entry and reader lock */
206 cache_return_entry_r( &li->li_cache, e );
208 /* front end with send result on success (rc==0) */