]> git.sur5r.net Git - openldap/blob - servers/slapd/kerberos.c
Happy new year!
[openldap] / servers / slapd / kerberos.c
1 /* kerberos.c - ldbm backend kerberos bind routines */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2006 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
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>.
15  */
16
17 #include "portable.h"
18
19 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
20
21 #include <stdio.h>
22
23 #include <ac/krb.h>
24 #include <ac/socket.h>
25 #include <ac/string.h>
26
27 #include "slap.h"
28
29 #define LDAP_KRB_PRINCIPAL      "ldapserver"
30
31 krbv4_ldap_auth(
32     Backend             *be,
33     struct berval       *cred,
34     AUTH_DAT            *ad
35 )
36 {
37         KTEXT_ST        k;
38         KTEXT           ktxt = &k;
39         char            instance[INST_SZ];
40         int             err;
41
42         Debug( LDAP_DEBUG_TRACE, "=> kerberosv4_ldap_auth\n", 0, 0, 0 );
43
44         AC_MEMCPY( ktxt->dat, cred->bv_val, cred->bv_len );
45         ktxt->length = cred->bv_len;
46
47         strcpy( instance, "*" );
48         if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad,
49             ldap_srvtab )) != KSUCCESS ) {
50                 Debug( LDAP_DEBUG_ANY, "krb_rd_req failed (%s)\n",
51                     krb_err_txt[err], 0, 0 );
52                 return( LDAP_INVALID_CREDENTIALS );
53         }
54
55         return( LDAP_SUCCESS );
56 }
57
58 #endif /* kerberos */