The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
directory.c File Reference

Determine remote server implementation and capabilities. More...

#include <freeradius-devel/ldap/base.h>
+ Include dependency graph for directory.c:

Go to the source code of this file.

Data Structures

struct  ldap_directory_discover_ctx_t
 State of an in progress rootDSE search on a connection being established. More...
 

Macros

#define LOG_PREFIX   name
 

Functions

static void _ldap_directory_discover_io_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, UNUSED int fd_errno, void *uctx)
 Error reading from or writing to the file descriptor.
 
static void _ldap_directory_discover_io_read (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
 Parse a rootDSE response from a server.
 
static int8_t _naming_context_cmp (void const *one, void const *two)
 Compare two naming contexts, case insensitively.
 
static uint32_t _naming_context_hash (void const *data)
 Hash a naming context, case insensitively.
 
int fr_ldap_conn_directory_alloc_async (fr_ldap_connection_t *ldap_conn)
 Asynchronously extract useful information from the rootDSE of the LDAP server.
 
fr_ldap_directory_tfr_ldap_directory_alloc (TALLOC_CTX *ctx)
 Allocate a directory structure with defaults.
 
char const * fr_ldap_directory_common_base_find (fr_ldap_directory_t const *directory, char const *const *dn_list)
 Find the naming context which contains a set of DNs.
 
int fr_ldap_directory_discover_async (fr_ldap_connection_t *c)
 Send a rootDSE search on a connection being established.
 
int fr_ldap_directory_result_parse (fr_ldap_directory_t *directory, LDAP *handle, LDAPMessage *result, char const *name)
 

Variables

static fr_table_num_sorted_t const fr_ldap_directory_type_table []
 
static size_t fr_ldap_directory_type_table_len = NUM_ELEMENTS(fr_ldap_directory_type_table)
 

Detailed Description

Determine remote server implementation and capabilities.

Id
8cf014313e7680ae4f6b9b1a2721b899bda20b9a

As described by http://ldapwiki.willeke.com/wiki/Determine%20LDAP%20Server%20Vendor

Definition in file directory.c.


Data Structure Documentation

◆ ldap_directory_discover_ctx_t

struct ldap_directory_discover_ctx_t

State of an in progress rootDSE search on a connection being established.

Definition at line 338 of file directory.c.

+ Collaboration diagram for ldap_directory_discover_ctx_t:
Data Fields
fr_ldap_connection_t * c Connection the rootDSE search was sent on.
int msgid Of the outstanding rootDSE search.

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   name

Definition at line 31 of file directory.c.

Function Documentation

◆ _ldap_directory_discover_io_error()

static void _ldap_directory_discover_io_error ( UNUSED fr_event_list_t el,
UNUSED int  fd,
UNUSED int  flags,
UNUSED int  fd_errno,
void *  uctx 
)
static

Error reading from or writing to the file descriptor.

Parameters
[in]elthe event occurred in.
[in]fdthe event occurred on.
[in]flagsfrom kevent.
[in]fd_errnoThe error that occurred.
[in]uctxdiscover_ctx containing the connection and message ID.

Definition at line 351 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _ldap_directory_discover_io_read()

static void _ldap_directory_discover_io_read ( UNUSED fr_event_list_t el,
UNUSED int  fd,
UNUSED int  flags,
void *  uctx 
)
static

Parse a rootDSE response from a server.

A failure parsing the rootDSE leaves the directory with its defaults, the connection is still usable, so the state machine advances either way.

Parameters
[in]elthe event occurred in.
[in]fdthe event occurred on.
[in]flagsfrom kevent.
[in]uctxdiscover_ctx containing the connection and message ID.

Definition at line 371 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _naming_context_cmp()

static int8_t _naming_context_cmp ( void const *  one,
void const *  two 
)
static

Compare two naming contexts, case insensitively.

Definition at line 63 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _naming_context_hash()

static uint32_t _naming_context_hash ( void const *  data)
static

Hash a naming context, case insensitively.

Definition at line 55 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_ldap_conn_directory_alloc_async()

int fr_ldap_conn_directory_alloc_async ( fr_ldap_connection_t ldap_conn)

Asynchronously extract useful information from the rootDSE of the LDAP server.

This version is for a single connection rather than a connection trunk

Parameters
[in]ldap_connconnection to be queried
Returns
  • message ID on success < 0 on failure

Definition at line 442 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_ldap_directory_alloc()

fr_ldap_directory_t * fr_ldap_directory_alloc ( TALLOC_CTX *  ctx)

Allocate a directory structure with defaults.

dn_attr defaults to the RFC 5020 entryDN attribute, overridden when parsing the rootDSE detects a directory which doesn't implement entryDN.

Definition at line 272 of file directory.c.

+ Here is the caller graph for this function:

◆ fr_ldap_directory_common_base_find()

char const * fr_ldap_directory_common_base_find ( fr_ldap_directory_t const *  directory,
char const *const *  dn_list 
)

Find the naming context which contains a set of DNs.

Looks up successively shorter suffixes of each DN in the hash table of naming contexts (database suffixes) built when the rootDSE was parsed, and returns the naming context containing every DN. A search with the returned base covers all the DNs.

Parameters
[in]directoryDirectory discovery results, providing the naming contexts.
[in]dn_listNULL terminated list of DNs to cover, no empty strings.
Returns
  • The matching naming context.
  • NULL if the directory hasn't been discovered yet, or no single naming context contains every DN.

Definition at line 296 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_ldap_directory_discover_async()

int fr_ldap_directory_discover_async ( fr_ldap_connection_t c)

Send a rootDSE search on a connection being established.

Called by the connection state machine after binding, so the directory capabilities (vendor, naming contexts) are known before the connection starts serving requests. Results are parsed into c->directory.

Parameters
[in]cLDAP connection to be queried.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 404 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_ldap_directory_result_parse()

int fr_ldap_directory_result_parse ( fr_ldap_directory_t directory,
LDAP *  handle,
LDAPMessage *  result,
char const *  name 
)

Definition at line 68 of file directory.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ fr_ldap_directory_type_table

fr_table_num_sorted_t const fr_ldap_directory_type_table[]
static
Initial value:
= {
{ L("Active Directory"), FR_LDAP_DIRECTORY_ACTIVE_DIRECTORY },
{ L("IBM"), FR_LDAP_DIRECTORY_IBM },
{ L("NetScape"), FR_LDAP_DIRECTORY_NETSCAPE },
{ L("OpenLDAP"), FR_LDAP_DIRECTORY_OPENLDAP },
{ L("Oracle Internet Directory"), FR_LDAP_DIRECTORY_ORACLE_INTERNET_DIRECTORY },
{ L("Oracle Unified Directory"), FR_LDAP_DIRECTORY_ORACLE_UNIFIED_DIRECTORY },
{ L("Oracle Virtual Directory"), FR_LDAP_DIRECTORY_ORACLE_VIRTUAL_DIRECTORY },
{ L("Samba"), FR_LDAP_DIRECTORY_SAMBA },
{ L("Siemens AG"), FR_LDAP_DIRECTORY_SIEMENS_AG },
{ L("Sun One Directory"), FR_LDAP_DIRECTORY_SUN_ONE_DIRECTORY },
{ L("Unbound ID"), FR_LDAP_DIRECTORY_UNBOUND_ID },
{ L("Unknown"), FR_LDAP_DIRECTORY_UNKNOWN },
{ L("eDirectory"), FR_LDAP_DIRECTORY_EDIRECTORY }
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:228
@ FR_LDAP_DIRECTORY_ORACLE_UNIFIED_DIRECTORY
Directory server is Oracle Unified Directory.
Definition base.h:149
@ FR_LDAP_DIRECTORY_UNKNOWN
We can't determine the directory server.
Definition base.h:141
@ FR_LDAP_DIRECTORY_NETSCAPE
Directory server is Netscape.
Definition base.h:146
@ FR_LDAP_DIRECTORY_EDIRECTORY
Directory server is eDir.
Definition base.h:144
@ FR_LDAP_DIRECTORY_ORACLE_INTERNET_DIRECTORY
Directory server is Oracle Internet Directory.
Definition base.h:148
@ FR_LDAP_DIRECTORY_UNBOUND_ID
Directory server is Unbound ID.
Definition base.h:153
@ FR_LDAP_DIRECTORY_SIEMENS_AG
Directory server is Siemens AG.
Definition base.h:152
@ FR_LDAP_DIRECTORY_ORACLE_VIRTUAL_DIRECTORY
Directory server is Oracle Virtual Directory.
Definition base.h:150
@ FR_LDAP_DIRECTORY_ACTIVE_DIRECTORY
Directory server is Active Directory.
Definition base.h:143
@ FR_LDAP_DIRECTORY_OPENLDAP
Directory server is OpenLDAP.
Definition base.h:147
@ FR_LDAP_DIRECTORY_SUN_ONE_DIRECTORY
Directory server is Sun One Directory.
Definition base.h:151
@ FR_LDAP_DIRECTORY_IBM
Directory server is IBM.
Definition base.h:145
@ FR_LDAP_DIRECTORY_SAMBA
Directory server is Samba.
Definition base.h:154

Definition at line 35 of file directory.c.

◆ fr_ldap_directory_type_table_len

size_t fr_ldap_directory_type_table_len = NUM_ELEMENTS(fr_ldap_directory_type_table)
static

Definition at line 50 of file directory.c.