1998-08-09 08:43:13 +08:00
|
|
|
/* kerberos.c - ldbm backend kerberos bind routines */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-27 09:17:14 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2004-01-02 03:15:16 +08:00
|
|
|
* Copyright 1998-2004 The OpenLDAP Foundation.
|
2003-11-27 09:17:14 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
1999-08-07 07:07:46 +08:00
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
|
1998-10-25 09:41:42 +08:00
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include <stdio.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
|
|
|
#include <ac/krb.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
#include "slap.h"
|
|
|
|
|
|
|
|
#define LDAP_KRB_PRINCIPAL "ldapserver"
|
|
|
|
|
|
|
|
krbv4_ldap_auth(
|
|
|
|
Backend *be,
|
|
|
|
struct berval *cred,
|
|
|
|
AUTH_DAT *ad
|
|
|
|
)
|
|
|
|
{
|
|
|
|
KTEXT_ST k;
|
|
|
|
KTEXT ktxt = &k;
|
|
|
|
char instance[INST_SZ];
|
|
|
|
int err;
|
|
|
|
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "=> kerberosv4_ldap_auth\n", 0, 0, 0 );
|
|
|
|
|
2000-07-28 09:07:07 +08:00
|
|
|
AC_MEMCPY( ktxt->dat, cred->bv_val, cred->bv_len );
|
1998-08-09 08:43:13 +08:00
|
|
|
ktxt->length = cred->bv_len;
|
|
|
|
|
|
|
|
strcpy( instance, "*" );
|
|
|
|
if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad,
|
2004-10-01 15:33:16 +08:00
|
|
|
SLAPD_GLOBAL(ldap_srvtab) )) != KSUCCESS ) {
|
1998-08-09 08:43:13 +08:00
|
|
|
Debug( LDAP_DEBUG_ANY, "krb_rd_req failed (%s)\n",
|
|
|
|
krb_err_txt[err], 0, 0 );
|
|
|
|
return( LDAP_INVALID_CREDENTIALS );
|
|
|
|
}
|
|
|
|
|
|
|
|
return( LDAP_SUCCESS );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* kerberos */
|