The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
LDAP module library functions. More...
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/ldap/base.h>
#include <freeradius-devel/unlang/function.h>
Go to the source code of this file.
Data Structures | |
struct | sync_ldap_query_t |
Macros | |
#define | do_ldap_global_option(_option, _name, _value) |
#define | LOG_PREFIX handle_config->name |
#define | maybe_ldap_global_option(_option, _name, _value) if (_value) do_ldap_global_option(_option, _name, _value) |
#define | SET_LDAP_CTRLS(_dest, _src) |
Functions | |
static int | _ldap_handle_thread_local_free (void *handle) |
static int | _ldap_query_free (fr_ldap_query_t *query) |
Free any libldap structures when an fr_ldap_query_t is freed. More... | |
fr_ldap_rcode_t | fr_ldap_delete_async (int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *dn, LDAPControl **serverctrls, LDAPControl **clientctrls) |
Modify something in the LDAP directory. More... | |
fr_ldap_rcode_t | fr_ldap_error_check (LDAPControl ***ctrls, fr_ldap_connection_t const *conn, LDAPMessage *msg, char const *dn) |
Perform basic parsing of multiple types of messages, checking for error conditions. More... | |
char const * | fr_ldap_error_str (fr_ldap_connection_t const *conn) |
Return the error string associated with a handle. More... | |
fr_ldap_query_t * | fr_ldap_extended_alloc (TALLOC_CTX *ctx, char const *reqoid, struct berval *reqdata, LDAPControl **serverctrls, LDAPControl **clientctrls) |
Allocate a new LDAP extended operations object. More... | |
fr_ldap_rcode_t | fr_ldap_extended_async (int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *reqoid, struct berval *reqdata) |
Initiate an LDAP extended operation. More... | |
int | fr_ldap_global_config (int debug_level, char const *tls_random_file) |
Change settings global to libldap. More... | |
LDAP * | fr_ldap_handle_thread_local (void) |
Get a thread local dummy LDAP handle. More... | |
int | fr_ldap_init (void) |
Initialise libldap and check library versions. More... | |
fr_ldap_query_t * | fr_ldap_modify_alloc (TALLOC_CTX *ctx, char const *dn, LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls) |
Allocate a new LDAP modify object. More... | |
fr_ldap_rcode_t | fr_ldap_modify_async (int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *dn, LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls) |
Modify something in the LDAP directory. More... | |
fr_ldap_rcode_t | fr_ldap_result (LDAPMessage **result, LDAPControl ***ctrls, fr_ldap_connection_t const *conn, int msgid, int all, char const *dn, fr_time_delta_t timeout) |
Parse response from LDAP server dealing with any errors. More... | |
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. More... | |
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. More... | |
void | fr_ldap_timeout_debug (request_t *request, fr_ldap_connection_t const *conn, fr_time_delta_t timeout, char const *prefix) |
Prints information to the debug log on the current timeout settings. More... | |
unlang_action_t | fr_ldap_trunk_extended (TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *reqoid, struct berval *reqdata, LDAPControl **serverctrls, LDAPControl **clientctrls) |
Run an async LDAP "extended operation" query on a trunk connection. More... | |
unlang_action_t | fr_ldap_trunk_modify (TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *dn, LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls) |
Run an async modification LDAP query on a trunk connection. More... | |
unlang_action_t | fr_ldap_trunk_search (TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *base_dn, int scope, char const *filter, char const *const *attrs, LDAPControl **serverctrls, LDAPControl **clientctrls) |
Run an async search LDAP query on a trunk connection. More... | |
static fr_ldap_query_t * | ldap_query_alloc (TALLOC_CTX *ctx, fr_ldap_request_type_t type) |
Allocate an fr_ldap_query_t, setting the talloc destructor. More... | |
static void | ldap_trunk_query_cancel (UNUSED request_t *request, UNUSED fr_signal_t action, void *uctx) |
Signal an LDAP query running on a trunk connection to cancel. More... | |
static unlang_action_t | ldap_trunk_query_results (rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx) |
Handle the return code from parsed LDAP results to set the module rcode. More... | |
static void | ldap_trunk_search_results_debug (request_t *request, fr_ldap_query_t *query) |
static void | libldap_free (void) |
Free any global libldap resources. More... | |
static int | libldap_init (void) |
Initialise libldap library and set global options. More... | |
LDAP module library functions.
Definition in file base.c.
struct sync_ldap_query_t |
Data Fields | ||
---|---|---|
fr_ldap_query_t * | query | |
LDAPMessage ** | result |
#define do_ldap_global_option | ( | _option, | |
_name, | |||
_value | |||
) |
#define maybe_ldap_global_option | ( | _option, | |
_name, | |||
_value | |||
) | if (_value) do_ldap_global_option(_option, _name, _value) |
#define SET_LDAP_CTRLS | ( | _dest, | |
_src | |||
) |
|
static |
|
static |
fr_ldap_rcode_t fr_ldap_delete_async | ( | int * | msgid, |
request_t * | request, | ||
fr_ldap_connection_t * | pconn, | ||
char const * | dn, | ||
LDAPControl ** | serverctrls, | ||
LDAPControl ** | clientctrls | ||
) |
Modify something in the LDAP directory.
Used on connections bound as the administrative user to attempt to modify an LDAP object. Called by the trunk mux function
[out] | msgid | LDAP message ID. |
[in] | request | Current request. |
[in] | pconn | to use. |
[in] | dn | of the object to delete. |
[in] | serverctrls | Search controls to pass to the server. May be NULL. |
[in] | clientctrls | Search controls for ldap_delete. May be NULL. |
Definition at line 840 of file base.c.
fr_ldap_rcode_t fr_ldap_error_check | ( | LDAPControl *** | ctrls, |
fr_ldap_connection_t const * | conn, | ||
LDAPMessage * | msg, | ||
char const * | dn | ||
) |
Perform basic parsing of multiple types of messages, checking for error conditions.
[out] | ctrls | Server ctrls returned to the client. May be NULL if not required. Must be freed with ldap_free_ctrls. |
[in] | conn | the message was received on. |
[in] | msg | we're parsing. |
[in] | dn | if processing the result from a search request. |
Definition at line 232 of file base.c.
char const* fr_ldap_error_str | ( | fr_ldap_connection_t const * | conn | ) |
fr_ldap_query_t* fr_ldap_extended_alloc | ( | TALLOC_CTX * | ctx, |
char const * | reqoid, | ||
struct berval * | reqdata, | ||
LDAPControl ** | serverctrls, | ||
LDAPControl ** | clientctrls | ||
) |
Allocate a new LDAP extended operations object.
[in] | ctx | to allocate the query in. |
[in] | reqoid | OID of extended operation to perform. |
[in] | reqdata | Request data to send. |
[in] | serverctrls | Controls to pass to the server. May be NULL. |
[in] | clientctrls | Client controls. May be NULL. |
Definition at line 1075 of file base.c.
fr_ldap_rcode_t fr_ldap_extended_async | ( | int * | msgid, |
request_t * | request, | ||
fr_ldap_connection_t * | pconn, | ||
char const * | reqoid, | ||
struct berval * | reqdata | ||
) |
Initiate an LDAP extended operation.
Called by the trunk mux function
[out] | msgid | LDAP message ID. |
[in] | request | Current request. |
[in] | pconn | to use. |
[in] | reqoid | OID of extended operation to perform. |
[in] | reqdata | Data required for the request. |
Definition at line 924 of file base.c.
int fr_ldap_global_config | ( | int | debug_level, |
char const * | tls_random_file | ||
) |
LDAP* fr_ldap_handle_thread_local | ( | void | ) |
Get a thread local dummy LDAP handle.
Many functions in the OpenLDAP API don't actually use the handle for anything other than writing out error codes.
This is true for most of the LDAP extensions API functions.
This gives us a reusable handle that was can pass to those functions when we don't already have one available.
Definition at line 1105 of file base.c.
int fr_ldap_init | ( | void | ) |
fr_ldap_query_t* fr_ldap_modify_alloc | ( | TALLOC_CTX * | ctx, |
char const * | dn, | ||
LDAPMod * | mods[], | ||
LDAPControl ** | serverctrls, | ||
LDAPControl ** | clientctrls | ||
) |
Allocate a new LDAP modify object.
[in] | ctx | to allocate the query in. |
[in] | dn | of the object to modify. |
[in] | mods | to apply to the object. |
[in] | serverctrls | Controls to pass to the server. May be NULL. |
[in] | clientctrls | Client controls. May be NULL. |
Definition at line 1052 of file base.c.
fr_ldap_rcode_t fr_ldap_modify_async | ( | int * | msgid, |
request_t * | request, | ||
fr_ldap_connection_t * | pconn, | ||
char const * | dn, | ||
LDAPMod * | mods[], | ||
LDAPControl ** | serverctrls, | ||
LDAPControl ** | clientctrls | ||
) |
Modify something in the LDAP directory.
Used on connections bound as the administrative user to attempt to modify an LDAP object. Called by the trunk mux function
[out] | msgid | LDAP message ID. |
[in] | request | Current request. |
[in] | pconn | to use. |
[in] | dn | of the object to modify. |
[in] | mods | to make, see 'man ldap_modify' for more information. |
[in] | serverctrls | Search controls to pass to the server. May be NULL. |
[in] | clientctrls | Search controls for ldap_modify. May be NULL. |
Definition at line 800 of file base.c.
fr_ldap_rcode_t fr_ldap_result | ( | LDAPMessage ** | result, |
LDAPControl *** | ctrls, | ||
fr_ldap_connection_t const * | conn, | ||
int | msgid, | ||
int | all, | ||
char const * | dn, | ||
fr_time_delta_t | timeout | ||
) |
Parse response from LDAP server dealing with any errors.
Should be called after an LDAP operation. Will check result of operation and if it was successful, then attempt to retrieve and parse the result. Will also produce extended error output including any messages the server sent, and information about partial DN matches.
[out] | result | Where to write result, if NULL result will be freed. If not NULL caller must free with ldap_msgfree(). |
[out] | ctrls | Server ctrls returned to the client. May be NULL if not required. Must be freed with ldap_free_ctrls. |
[in] | conn | Current connection. |
[in] | msgid | returned from last operation. Special values are:
|
[in] | all | How many messages to retrieve:
|
[in] | dn | Last search or bind DN. May be NULL. |
[in] | timeout | Override the default result timeout. |
Definition at line 449 of file base.c.
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.
[in] | ctx | to allocate query in. |
[in] | base_dn | for the search. |
[in] | scope | of the search. |
[in] | filter | for the search |
[in] | attrs | to request. |
[in] | serverctrls | Search controls to pass to the server. May be NULL. |
[in] | clientctrls | Client controls. May be NULL. |
Definition at line 1026 of file base.c.
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.
Performs an LDAP search, typically on a connection bound as the administrative user, dealing with any errors. Called from the trunk mux function and elsewhere where appropriate event handlers have been set on the connection fd.
[out] | msgid | to match response to request. |
[in] | request | Current request. |
[in] | pconn | to use. |
[in] | dn | to use as base for the search. |
[in] | scope | to use (LDAP_SCOPE_BASE, LDAP_SCOPE_ONE, LDAP_SCOPE_SUB). |
[in] | filter | to use, should be pre-escaped. |
[in] | attrs | to retrieve. |
[in] | serverctrls | Search controls to pass to the server. May be NULL. |
[in] | clientctrls | Search controls for ldap_search. May be NULL. |
Definition at line 528 of file base.c.
void fr_ldap_timeout_debug | ( | request_t * | request, |
fr_ldap_connection_t const * | conn, | ||
fr_time_delta_t | timeout, | ||
char const * | prefix | ||
) |
Prints information to the debug log on the current timeout settings.
There are so many different timers in LDAP it's often hard to debug issues with them, hence the need for this function.
Definition at line 152 of file base.c.
unlang_action_t fr_ldap_trunk_extended | ( | TALLOC_CTX * | ctx, |
fr_ldap_query_t ** | out, | ||
request_t * | request, | ||
fr_ldap_thread_trunk_t * | ttrunk, | ||
char const * | reqoid, | ||
struct berval * | reqdata, | ||
LDAPControl ** | serverctrls, | ||
LDAPControl ** | clientctrls | ||
) |
Run an async LDAP "extended operation" query on a trunk connection.
[in] | ctx | to allocate the query in. |
[out] | out | that has been allocated. |
[in] | request | this query relates to. |
[in] | ttrunk | to submit the query to. |
[in] | reqoid | OID of extended operation. |
[in] | reqdata | Request data to send. |
[in] | serverctrls | specific to this query. |
[in] | clientctrls | specific to this query. |
Definition at line 881 of file base.c.
unlang_action_t fr_ldap_trunk_modify | ( | TALLOC_CTX * | ctx, |
fr_ldap_query_t ** | out, | ||
request_t * | request, | ||
fr_ldap_thread_trunk_t * | ttrunk, | ||
char const * | dn, | ||
LDAPMod * | mods[], | ||
LDAPControl ** | serverctrls, | ||
LDAPControl ** | clientctrls | ||
) |
Run an async modification LDAP query on a trunk connection.
[in] | ctx | to allocate the query in. |
[out] | out | that has been allocated. |
[in] | request | this query relates to. |
[in] | ttrunk | to submit the query to. |
[in] | dn | of the object being modified. |
[in] | mods | to be performed. |
[in] | serverctrls | specific to this query. |
[in] | clientctrls | specific to this query. |
Definition at line 754 of file base.c.
unlang_action_t fr_ldap_trunk_search | ( | TALLOC_CTX * | ctx, |
fr_ldap_query_t ** | out, | ||
request_t * | request, | ||
fr_ldap_thread_trunk_t * | ttrunk, | ||
char const * | base_dn, | ||
int | scope, | ||
char const * | filter, | ||
char const *const * | attrs, | ||
LDAPControl ** | serverctrls, | ||
LDAPControl ** | clientctrls | ||
) |
Run an async search LDAP query on a trunk connection.
[in] | ctx | to allocate the query in. |
[out] | out | that has been allocated. |
[in] | request | this query relates to. |
[in] | ttrunk | to submit the query to. |
[in] | base_dn | for the search. |
[in] | scope | of the search. |
[in] | filter | for the search. |
[in] | attrs | to be returned. |
[in] | serverctrls | specific to this query. |
[in] | clientctrls | specific to this query. |
Definition at line 708 of file base.c.
|
inlinestatic |
|
static |
|
static |
|
static |
|
static |
|
static |
fr_table_num_sorted_t const fr_ldap_connection_states[] |
size_t fr_ldap_connection_states_len = NUM_ELEMENTS(fr_ldap_connection_states) |
fr_table_num_sorted_t const fr_ldap_dereference[] |
size_t fr_ldap_dereference_len = NUM_ELEMENTS(fr_ldap_dereference) |
fr_table_num_sorted_t const fr_ldap_scope[] |
size_t fr_ldap_scope_len = NUM_ELEMENTS(fr_ldap_scope) |
fr_table_num_sorted_t const fr_ldap_supported_extensions[] |
size_t fr_ldap_supported_extensions_len = NUM_ELEMENTS(fr_ldap_supported_extensions) |
fr_table_num_sorted_t const fr_ldap_tls_require_cert[] |
size_t fr_ldap_tls_require_cert_len = NUM_ELEMENTS(fr_ldap_tls_require_cert) |
global_lib_autoinst_t fr_libldap_global_config |
|
static |
LDAP* ldap_global_handle |
|
static |
|
static |
|
static |