]> git.sur5r.net Git - openldap/blob - servers/slapd/passwd.c
reduce slap_passwd_check to simple form
[openldap] / servers / slapd / passwd.c
1 /* bind.c - ldbm backend bind and unbind routines */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/krb.h>
13 #include <ac/socket.h>
14 #include <ac/string.h>
15 #include <ac/unistd.h>
16
17 #include "slap.h"
18
19 #include <lutil.h>
20
21
22 int
23 slap_passwd_check(
24         Attribute *a,
25         struct berval           *cred
26 )
27 {
28         int     i;
29         for ( i = 0; a->a_vals[i] != NULL; i++ ) {
30                 if ( a->a_syntax == SYNTAX_BIN ) {
31                         int result;
32
33 #ifdef SLAPD_CRYPT
34                         ldap_pvt_thread_mutex_lock( &crypt_mutex );
35 #endif
36
37                         result = lutil_passwd(
38                                 (char*) cred->bv_val,
39                                 (char*) a->a_vals[i]->bv_val,
40                                 NULL );
41
42 #ifdef SLAPD_CRYPT
43                         ldap_pvt_thread_mutex_unlock( &crypt_mutex );
44 #endif
45
46                         return result;
47
48                 } else {
49                 if ( value_cmp( a->a_vals[i], cred, a->a_syntax, 1 ) == 0 ) {
50                         return( 0 );
51                 }
52         }
53         }
54
55         return( 1 );
56 }