kdb_ldap.h revision 159d09a20817016f09b3ea28d1bdada4a336bb91
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* Copyright (c) 2004-2005, Novell, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* * The copyright holder's name is not used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* */
#ifndef _KDB_LDAP_H
#define _KDB_LDAP_H 1
/* We want the interfaces marked "deprecated" in OpenLDAP. */
#define LDAP_DEPRECATED 1
#include <ldap.h>
/* Check for acceptable versions.
OpenLDAP version 2.2.6 is known to have some kind of problem that
is tickled by the use of multiple handles in this code. Version
2.2.19 in Mac OS 10.4.7 seems to be buggy as well. Version 2.2.24
doesn't have this problem. Other in-between versions have not been
tested. */
#ifndef BUILD_WITH_BROKEN_LDAP
# if defined(LDAP_API_FEATURE_X_OPENLDAP)
# if LDAP_VENDOR_VERSION < 20224
# endif
# endif
#endif /* BUILD_WITH_BROKEN_LDAP */
#include <k5-thread.h>
#include <k5-platform.h> /* Solaris Kerberos */
#include <k5-platform-store_16.h>
#include <k5-platform-store_32.h>
#include <k5-platform-load_16.h>
#include <k5-platform-load_32.h>
#include <kdb5.h>
#include "k5-int.h"
#include "ldap_krbcontainer.h"
#include "ldap_realm.h"
/* Solaris Kerberos: need this define to get around sccs keyword expansion */
#define DATE_FORMAT "%Y" "%m" "%d" "%H" "%M" "%SZ"
#define SERV_COUNT 100
#define DEFAULT_CONNS_PER_SERVER 5
#ifdef HAVE_EDIRECTORY
#define SECURITY_CONTAINER "cn=Security"
#define KERBEROS_CONTAINER "cn=Kerberos,cn=Security"
#endif
#if !defined(LDAP_OPT_RESULT_CODE) && defined(LDAP_OPT_ERROR_NUMBER)
#endif
#define MAXINTLEN 10
#define IGNORE_STATUS 0
#define CHECK_STATUS 1
return EINVAL; \
} \
return KRB5_KDB_DBNOTINITED;
if (st != 0) { \
st = KRB5_KDB_ACCESS_ERROR; \
goto cleanup; \
} \
extern void prepend_err_str (krb5_context ctx, const char *s, krb5_error_code err, krb5_error_code oerr);
#define LDAP_SEARCH(base, scope, filter, attrs) LDAP_SEARCH_1(base, scope, filter, attrs, CHECK_STATUS)
do { \
st = ldap_search_ext_s(ld, base, scope, filter, attrs, 0, NULL, NULL, &timelimit, LDAP_NO_LIMIT, &result); \
if (ldap_server_handle) \
} \
\
if (status_check != IGNORE_STATUS) { \
if (tempst != 0) { \
st = KRB5_KDB_ACCESS_ERROR; \
goto cleanup; \
} \
if (st != LDAP_SUCCESS) { \
goto cleanup; \
} \
}
} \
goto cleanup; \
}
goto cleanup; \
}
#define KRB5_CONF_KDC_BIND_DN "ldap_kdc_dn"
#define KRB5_CONF_ADMIN_BIND_DN "ldap_kadmind_dn"
#define KRB5_CONF_PWD_BIND_DN "ldap_passwd_dn"
#define KDB_TL_USER_INFO 0x7ffe
#define KDB_TL_PRINCTYPE 0x01
#define KDB_TL_PRINCCOUNT 0x02
#define KDB_TL_USERDN 0x03
#define KDB_TL_KEYINFO 0x04
#define KDB_TL_MASK 0x05
#define KDB_TL_CONTAINERDN 0x06
#define KDB_TL_LINKDN 0x07
&& ldap_context->server_info_list)) { \
return KRB5_KDB_DBNOTINITED; \
}
/* To be used later */
typedef struct _krb5_ldap_certificates{
char *certificate;
int certtype;
/* ldap server info structure */
typedef struct _krb5_ldap_server_info krb5_ldap_server_info;
typedef struct _krb5_ldap_server_handle {
int msgid;
struct _krb5_ldap_server_handle *next;
struct _krb5_ldap_server_info {
char *server_name;
#ifdef HAVE_EDIRECTORY
char *root_certificate_file;
#endif
struct _krb5_ldap_server_info *next;
};
/* ldap server structure */
typedef struct _krb5_ldap_context {
char *conf_section;
char *bind_dn;
char *bind_pwd;
char *service_password_file;
char *root_certificate_file;
char *service_cert_path;
char *service_cert_pass;
typedef struct {
int nkey;
}KEY;
#define k5ldap_inited(c) (c && c->db_context \
/* misc functions */
krb5_ldap_lib_init(void);
krb5_ldap_lib_cleanup(void);
void *
void
krb5_ldap_create(krb5_context , char *, char **);
krb5_ldap_open( krb5_context , char *,
char **db_args,
int mode );
int
has_sasl_external_mech(krb5_context, char *);
/* DAL functions */
krb5_ldap_set_option( krb5_context, int, void * );
krb5_ldap_lock( krb5_context, int );
krb5_ldap_supported_realms( krb5_context, char ** );
krb5_ldap_free_supported_realms( krb5_context, char ** );
const char *
krb5_ldap_errcode_2_string( krb5_context, long );
void
krb5_ldap_release_errcode_string (krb5_context, const char *);
#ifndef HAVE_LDAP_INITIALIZE
/* Solaris Kerberos: added a use_SSL parameter */
int
ldap_initialize(LDAP **, char *, int, char **);
#endif
#ifndef HAVE_LDAP_UNBIND_EXT_S
int
#endif
#endif