]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/kerberos.c
New dn2id format with base/one/subtree indices (ldbm/bdb2)
[openldap] / servers / slapd / back-ldbm / kerberos.c
1 /* kerberos.c - ldbm backend kerberos bind routines */
2 /*
3  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #ifdef HAVE_KERBEROS
10
11 #include <stdio.h>
12
13 #include <ac/krb.h>
14 #include <ac/socket.h>
15 #include <ac/string.h>
16
17 #include "slap.h"
18 #include "back-ldbm.h"
19
20 #define LDAP_KRB_PRINCIPAL      "ldapserver"
21
22 extern char             *ldap_srvtab;
23 extern Attribute        *attr_find();
24
25 krbv4_ldap_auth(
26     Backend             *be,
27     struct berval       *cred,
28     AUTH_DAT            *ad
29 )
30 {
31         KTEXT_ST        k;
32         KTEXT           ktxt = &k;
33         char            instance[INST_SZ];
34         int             err;
35
36         Debug( LDAP_DEBUG_TRACE, "=> kerberosv4_ldap_auth\n", 0, 0, 0 );
37
38         SAFEMEMCPY( ktxt->dat, cred->bv_val, cred->bv_len );
39         ktxt->length = cred->bv_len;
40
41         strcpy( instance, "*" );
42         if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad,
43             ldap_srvtab )) != KSUCCESS ) {
44                 Debug( LDAP_DEBUG_ANY, "krb_rd_req failed (%s)\n",
45                     krb_err_txt[err], 0, 0 );
46                 return( LDAP_INVALID_CREDENTIALS );
47         }
48
49         return( LDAP_SUCCESS );
50 }
51
52 #endif /* kerberos */