1998-08-09 08:43:13 +08:00
|
|
|
/* kerberos.c - ldbm backend kerberos bind routines */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-08-07 07:07:46 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_KERBEROS
|
|
|
|
|
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"
|
|
|
|
#include "back-ldbm.h"
|
|
|
|
|
|
|
|
#define LDAP_KRB_PRINCIPAL "ldapserver"
|
|
|
|
|
|
|
|
extern char *ldap_srvtab;
|
|
|
|
extern Attribute *attr_find();
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
SAFEMEMCPY( ktxt->dat, cred->bv_val, cred->bv_len );
|
|
|
|
ktxt->length = cred->bv_len;
|
|
|
|
|
|
|
|
strcpy( instance, "*" );
|
|
|
|
if ( (err = krb_rd_req( ktxt, LDAP_KRB_PRINCIPAL, instance, 0L, ad,
|
|
|
|
ldap_srvtab )) != KSUCCESS ) {
|
|
|
|
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 */
|