27 RCSID(
"$Id: 9fe1c5b3c4c359e9bccf37262d43efd6380fa270 $")
31 #define LOG_PREFIX name
33 #include <freeradius-devel/ldap/base.h>
53 LDAPMessage *result,
char const *
name)
55 int entry_cnt, i, num, ldap_errno;
57 struct berval **values = NULL;
59 entry_cnt = ldap_count_entries(handle, result);
61 WARN(
"Capability check failed: Ambiguous result for rootDSE, expected 1 entry, got %i", entry_cnt);
65 entry = ldap_first_entry(handle, result);
67 ldap_get_option(handle, LDAP_OPT_RESULT_CODE, &ldap_errno);
69 WARN(
"Capability check failed: Failed retrieving entry: %s", ldap_err2string(ldap_errno));
73 values = ldap_get_values_len(handle, entry,
"vendorname");
78 ldap_value_free_len(values);
81 values = ldap_get_values_len(handle, entry,
"vendorversion");
86 ldap_value_free_len(values);
90 if (strcasestr(directory->
vendor_str,
"International Business Machines")) {
92 }
else if (strcasestr(directory->
vendor_str,
"Samba Team")) {
103 if (strcasestr(directory->
version_str,
"eDirectory")) {
108 }
else if (strcasestr(directory->
version_str,
"Oracle Unified Directory")) {
113 }
else if (strcasestr(directory->
version_str,
"UnboundID")) {
118 }
else if (strcasestr(directory->
version_str,
"Netscape-Directory")) {
123 }
else if (strcasestr(directory->
version_str,
"DirX Directory")) {
128 }
else if (strcasestr(directory->
version_str,
"Sun Java")) {
138 values = ldap_get_values_len(handle, entry,
"isGlobalCatalogReady");
141 ldap_value_free_len(values);
148 values = ldap_get_values_len(handle, entry,
"objectClass");
150 num = ldap_count_values_len(values);
151 for (i = 0; i < num; i++) {
152 if (strncmp(
"OpenLDAProotDSE", values[i]->bv_val, values[i]->bv_len) == 0) {
156 ldap_value_free_len(values);
163 values = ldap_get_values_len(handle, entry,
"orcldirectoryversion");
165 if (memmem(values[0]->bv_val, values[0]->bv_len,
"OID", 3)) {
167 }
else if (memmem(values[0]->bv_val, values[0]->bv_len,
"OVD", 3)) {
170 ldap_value_free_len(values);
176 switch (directory->
type) {
191 values = ldap_get_values_len(handle, entry,
"supportedControl");
193 num = ldap_count_values_len(values);
194 for (i = 0; i < num; i++) {
195 if (strncmp(LDAP_CONTROL_SYNC, values[i]->bv_val, values[i]->bv_len) == 0) {
196 INFO(
"Directory supports RFC 4533");
201 INFO(
"Directory supports LDAP_SERVER_NOTIFICATION_OID");
205 if (strncmp(LDAP_CONTROL_PERSIST_REQUEST, values[i]->bv_val, values[i]->bv_len) == 0) {
206 INFO(
"Directory supports persistent search");
211 ldap_value_free_len(values);
213 WARN(
"No supportedControl returned by LDAP server");
219 values = ldap_get_values_len(handle, entry,
"namingContexts");
220 if (!values)
return 0;
222 num = ldap_count_values_len(values);
223 directory->
naming_contexts = talloc_array(directory,
char const *, num);
224 for (i = 0; i < num; i++) {
227 ldap_value_free_len(values);
267 if (!treq)
return -1;
295 if (
fr_ldap_search_async(&msgid, NULL, ldap_conn,
"", LDAP_SCOPE_BASE,
"(objectclass=*)", attrs,
#define USES_APPLE_DEPRECATED_API
#define L(_str)
Helper for initialising arrays of string literals.
int fr_ldap_conn_directory_alloc_async(fr_ldap_connection_t *ldap_conn)
Async extract useful information from the rootDSE of the LDAP server.
int fr_ldap_trunk_directory_alloc_async(TALLOC_CTX *ctx, fr_ldap_thread_trunk_t *ttrunk)
Async extract useful information from the rootDSE of the LDAP server.
static fr_table_num_sorted_t const fr_ldap_directory_type_table[]
static void ldap_trunk_directory_alloc_read(LDAP *handle, fr_ldap_query_t *query, LDAPMessage *result, void *rctx)
Parse results of search on rootDSE to gather data on LDAP server.
int fr_ldap_directory_result_parse(fr_ldap_directory_t *directory, LDAP *handle, LDAPMessage *result, char const *name)
static size_t fr_ldap_directory_type_table_len
#define LDAP_DIRECTORY_ATTRS
#define LDAP_SERVER_NOTIFICATION_OID
OID of Active Directory control for.
@ FR_LDAP_DIRECTORY_ORACLE_UNIFIED_DIRECTORY
Directory server is Oracle Unified Directory.
@ FR_LDAP_DIRECTORY_UNKNOWN
We can't determine the directory server.
@ FR_LDAP_DIRECTORY_NETSCAPE
Directory server is Netscape.
@ FR_LDAP_DIRECTORY_EDIRECTORY
Directory server is eDir.
@ FR_LDAP_DIRECTORY_ORACLE_INTERNET_DIRECTORY
Directory server is Oracle Internet Directory.
@ FR_LDAP_DIRECTORY_UNBOUND_ID
Directory server is Unbound ID.
@ FR_LDAP_DIRECTORY_SIEMENS_AG
Directory server is Siemens AG.
@ FR_LDAP_DIRECTORY_ORACLE_VIRTUAL_DIRECTORY
Directory server is Oracle Virtual Directory.
@ FR_LDAP_DIRECTORY_ACTIVE_DIRECTORY
Directory server is Active Directory.
@ FR_LDAP_DIRECTORY_OPENLDAP
Directory server is OpenLDAP.
@ FR_LDAP_DIRECTORY_SUN_ONE_DIRECTORY
Directory server is Sun One Directory.
@ FR_LDAP_DIRECTORY_IBM
Directory server is IBM.
@ FR_LDAP_DIRECTORY_SAMBA
Directory server is Samba.
fr_ldap_sync_type_t sync_type
What kind of LDAP sync this directory supports.
fr_ldap_result_parser_t parser
Custom results parser.
fr_ldap_directory_t * directory
The type of directory we're connected to.
trunk_request_t * treq
Trunk request this query is associated with.
fr_ldap_config_t const * config
rlm_ldap connection configuration.
char * fr_ldap_berval_to_string(TALLOC_CTX *ctx, struct berval const *in)
Convert a berval to a talloced string.
char const * vendor_str
As returned from the vendorName attribute in the rootDSE.
fr_ldap_connection_t * ldap_conn
LDAP connection this query is running on.
bool cleartext_password
Whether the server will return the user's plaintext password.
@ FR_LDAP_SYNC_ACTIVE_DIRECTORY
Directory supports AD style persistent search.
@ FR_LDAP_SYNC_PERSISTENT_SEARCH
Directory supports persistent search.
@ FR_LDAP_SYNC_RFC4533
Directory supports RFC 4533.
fr_ldap_directory_t * directory
The type of directory we're connected to.
char const * version_str
As returned from the vendorVersion attribute in the rootDSE.
trunk_t * trunk
Connection trunk.
char const ** naming_contexts
Databases served by this directory.
fr_ldap_directory_type_t type
Canonical server implementation.
@ LDAP_PROC_SUCCESS
Operation was successful.
Connection configuration.
Tracks the state of a libldap connection handle.
Thread LDAP trunk structure.
fr_ldap_rcode_t fr_ldap_search_async(int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *dn, int scope, char const *filter, char const *const *attrs, LDAPControl **serverctrls, LDAPControl **clientctrls)
Search for something in the LDAP directory.
fr_ldap_query_t * fr_ldap_search_alloc(TALLOC_CTX *ctx, char const *base_dn, int scope, char const *filter, char const *const *attrs, LDAPControl **serverctrls, LDAPControl **clientctrls)
Allocate a new search object.
static const conf_parser_t config[]
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
An element in a lexicographically sorted array of name to num mappings.
trunk_enqueue_t trunk_request_enqueue(trunk_request_t **treq_out, trunk_t *trunk, request_t *request, void *preq, void *rctx)
Enqueue a request that needs data written to the trunk.
trunk_request_t * trunk_request_alloc(trunk_t *trunk, request_t *request)
(Pre-)Allocate a new trunk request