All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ldap.h File Reference

LDAP authorization and authentication module headers. More...

#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
#include <lber.h>
#include <ldap.h>
#include "config.h"
+ Include dependency graph for ldap.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ldap_acct_section
 
struct  ldap_handle
 Tracks the state of a libldap connection handle. More...
 
struct  ldap_instance
 
struct  ldap_sasl
 
struct  ldap_sasl_dynamic
 
struct  rlm_ldap_control
 
struct  rlm_ldap_map_exp
 Result of expanding the RHS of a set of maps. More...
 
struct  rlm_ldap_result
 Contains a collection of values. More...
 

Macros

#define LDAP_DBG(fmt,...)   radlog(L_DBG, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)
 
#define LDAP_DBG2(fmt,...)   if (rad_debug_lvl >= L_DBG_LVL_2) radlog(L_DBG, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)
 
#define LDAP_DBG3(fmt,...)   if (rad_debug_lvl >= L_DBG_LVL_3) radlog(L_DBG, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)
 
#define LDAP_DBG_REQ(fmt,...)   do { if (request) {RDEBUG(fmt, ##__VA_ARGS__);} else {LDAP_DBG(fmt, ##__VA_ARGS__);}} while (0)
 
#define LDAP_DBG_REQ2(fmt,...)   do { if (request) {RDEBUG2(fmt, ##__VA_ARGS__);} else if (rad_debug_lvl >= L_DBG_LVL_2) {LDAP_DBG(fmt, ##__VA_ARGS__);}} while (0)
 
#define LDAP_DBG_REQ3(fmt,...)   do { if (request) {RDEBUG3(fmt, ##__VA_ARGS__);} else if (rad_debug_lvl >= L_DBG_LVL_3) {LDAP_DBG(fmt, ##__VA_ARGS__);}} while (0)
 
#define LDAP_DBGW(fmt,...)   radlog(L_DBG_WARN, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)
 
#define LDAP_DBGW_REQ(fmt,...)   do { if (request) {RWDEBUG(fmt, ##__VA_ARGS__);} else {LDAP_DBGW(fmt, ##__VA_ARGS__);}} while (0)
 
#define LDAP_DEPRECATED   1
 
#define LDAP_ERR(fmt,...)   ERROR("rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)
 
#define LDAP_ERR_REQ(fmt,...)   do { if (request) {REDEBUG(fmt, ##__VA_ARGS__);} else {LDAP_ERR(fmt, ##__VA_ARGS__);}} while (0)
 
#define LDAP_EXT()   if (extra) LDAP_ERR(extra)
 
#define LDAP_EXT_REQ()   do { if (extra) { if (request) REDEBUG("%s", extra); else LDAP_ERR("%s", extra); }} while (0)
 
#define LDAP_INFO(fmt,...)   INFO("rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)
 
#define LDAP_MAP_RESERVED   4
 Number of additional items to allocate in expanded. More...
 
#define LDAP_MAX_ATTR_STR_LEN   256
 Maximum length of an xlat expanded LDAP attribute. More...
 
#define LDAP_MAX_ATTRMAP   128
 Maximum number of mappings between LDAP and. More...
 
#define LDAP_MAX_CACHEABLE   64
 Maximum number of groups we retrieve from the server for. More...
 
#define LDAP_MAX_CONTROLS   10
 Maximum number of client/server controls. More...
 
#define LDAP_MAX_DN_STR_LEN   1024
 Maximum length of an xlat expanded DN. More...
 
#define LDAP_MAX_FILTER_STR_LEN   1024
 Maximum length of an xlat expanded filter. More...
 
#define LDAP_MAX_GROUP_NAME_LEN   128
 Maximum name of a group name. More...
 
#define LDAP_VENDOR_VERSION_PATCH   0
 
#define LDAP_VIRTUAL_DN_ATTR   "dn"
 'Virtual' attribute which maps to the DN of the object. More...
 
#define LDAP_WARN(fmt,...)   WARN("rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)
 
#define MOD_PREFIX   "rlm_ldap"
 The name of the module. More...
 

Typedefs

typedef struct ldap_acct_section ldap_acct_section_t
 
typedef struct ldap_handle ldap_handle_t
 Tracks the state of a libldap connection handle. More...
 
typedef struct ldap_sasl ldap_sasl
 
typedef struct ldap_sasl_dynamic ldap_sasl_dynamic
 
typedef struct rlm_ldap_control rlm_ldap_control_t
 
typedef struct rlm_ldap_map_exp rlm_ldap_map_exp_t
 Result of expanding the RHS of a set of maps. More...
 
typedef struct rlm_ldap_result rlm_ldap_result_t
 Contains a collection of values. More...
 
typedef struct ldap_instance rlm_ldap_t
 

Enumerations

enum  ldap_rcode_t {
  LDAP_PROC_CONTINUE = 1,
  LDAP_PROC_SUCCESS = 0,
  LDAP_PROC_ERROR = -1,
  LDAP_PROC_RETRY = -2,
  LDAP_PROC_NOT_PERMITTED = -3,
  LDAP_PROC_REJECT = -4,
  LDAP_PROC_BAD_DN = -5,
  LDAP_PROC_NO_RESULT = -6
}
 Codes returned by rlm_ldap internal functions. More...
 
enum  ldap_supported_extension {
  LDAP_EXT_UNSUPPORTED,
  LDAP_EXT_BINDNAME,
  LDAP_EXT_BINDPW
}
 

Functions

char const * edir_errstr (int code)
 
void * mod_conn_create (TALLOC_CTX *ctx, void *instance, struct timeval const *timeout)
 Create a new connection pool handle. More...
 
ldap_handle_tmod_conn_get (rlm_ldap_t const *inst, REQUEST *request)
 
void mod_conn_release (rlm_ldap_t const *inst, ldap_handle_t *conn)
 Frees an LDAP socket back to the connection pool. More...
 
int nmasldap_get_password (LDAP *ld, char const *dn, char *password, size_t *len)
 Attempt to retrieve the universal password from Novell eDirectory. More...
 
char * rlm_ldap_berval_to_string (TALLOC_CTX *ctx, struct berval const *in)
 Convert a berval to a talloced string. More...
 
ldap_rcode_t rlm_ldap_bind (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, char const *dn, char const *password, ldap_sasl *sasl, bool retry, LDAPControl **serverctrls, LDAPControl **clientctrls)
 Bind to the LDAP directory as a user. More...
 
rlm_rcode_t rlm_ldap_cacheable_groupobj (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn)
 Convert group membership information into attributes. More...
 
rlm_rcode_t rlm_ldap_cacheable_userobj (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, LDAPMessage *entry, char const *attr)
 Convert group membership information into attributes. More...
 
rlm_rcode_t rlm_ldap_check_access (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t const *conn, LDAPMessage *entry)
 Check for presence of access attribute in result. More...
 
rlm_rcode_t rlm_ldap_check_cached (rlm_ldap_t const *inst, REQUEST *request, VALUE_PAIR *check)
 Check group membership attributes to see if a user is a member. More...
 
rlm_rcode_t rlm_ldap_check_groupobj_dynamic (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, VALUE_PAIR *check)
 Query the LDAP directory to check if a group object includes a user object as a member. More...
 
void rlm_ldap_check_reply (rlm_ldap_t const *inst, REQUEST *request)
 Verify we got a password from the search. More...
 
rlm_rcode_t rlm_ldap_check_userobj_dynamic (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, char const *dn, VALUE_PAIR *check)
 Query the LDAP directory to check if a user object is a member of a group. More...
 
int rlm_ldap_client_load (rlm_ldap_t const *inst, CONF_SECTION *tmpl, CONF_SECTION *cs)
 Load clients from LDAP on server start. More...
 
int rlm_ldap_control_add_client (ldap_handle_t *conn, LDAPControl *ctrl, bool freeit)
 Add a clientctrl to a connection handle. More...
 
int rlm_ldap_control_add_server (ldap_handle_t *conn, LDAPControl *ctrl, bool freeit)
 Add a serverctrl to a connection handle. More...
 
int rlm_ldap_control_add_session_tracking (ldap_handle_t *conn, REQUEST *request)
 
void rlm_ldap_control_clear (ldap_handle_t *conn)
 Clear and free any controls associated with a connection. More...
 
void rlm_ldap_control_merge (LDAPControl *serverctrls_out[], LDAPControl *clientctrls_out[], size_t serverctrls_len, size_t clientctrls_len, ldap_handle_t *conn, LDAPControl *serverctrls_in[], LDAPControl *clientctrls_in[])
 Merge connection and call specific client and server controls. More...
 
char const * rlm_ldap_error_str (ldap_handle_t const *conn)
 Return the error string associated with a handle. More...
 
size_t rlm_ldap_escape_func (UNUSED REQUEST *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
 Converts "bad" strings into ones which are safe for LDAP. More...
 
char const * rlm_ldap_find_user (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, char const *attrs[], bool force, LDAPMessage **result, rlm_rcode_t *rcode)
 Retrieve the DN of a user object. More...
 
bool rlm_ldap_is_dn (char const *in, size_t inlen)
 Check whether a string looks like a DN. More...
 
int rlm_ldap_map_do (rlm_ldap_t const *inst, REQUEST *request, LDAP *handle, rlm_ldap_map_exp_t const *expanded, LDAPMessage *entry)
 Convert attribute map into valuepairs. More...
 
int rlm_ldap_map_expand (rlm_ldap_map_exp_t *expanded, REQUEST *request, vp_map_t const *maps)
 Expand values in an attribute map where needed. More...
 
int rlm_ldap_map_getvalue (TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx)
 Callback for map_to_request. More...
 
int rlm_ldap_map_verify (vp_map_t *map, void *instance)
 
ldap_rcode_t rlm_ldap_modify (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t **pconn, char const *dn, LDAPMod *mods[], LDAPControl **serverctrls, LDAPControl **clientctrls)
 Modify something in the LDAP directory. More...
 
size_t rlm_ldap_normalise_dn (char *out, char const *in)
 Normalise escape sequences in a DN. More...
 
ldap_rcode_t rlm_ldap_result (rlm_ldap_t const *inst, ldap_handle_t const *conn, int msgid, char const *dn, LDAPMessage **result, char const **error, char **extra)
 Parse response from LDAP server dealing with any errors. More...
 
ldap_rcode_t rlm_ldap_sasl_interactive (rlm_ldap_t const *inst, REQUEST *request, ldap_handle_t *pconn, char const *dn, char const *password, ldap_sasl *sasl, LDAPControl **serverctrls, LDAPControl **clientctrls, char const **error, char **error_extra)
 Initiate an LDAP interactive bind. More...
 
ldap_rcode_t rlm_ldap_search (LDAPMessage **result, rlm_ldap_t const *inst, REQUEST *request, ldap_handle_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...
 
size_t rlm_ldap_unescape_func (UNUSED REQUEST *request, char *out, size_t outlen, char const *in, UNUSED void *arg)
 Converts escaped DNs and filter strings into normal. More...
 
ssize_t rlm_ldap_xlat_filter (REQUEST *request, char const **sub, size_t sublen, char *out, size_t outlen)
 Combine and expand filters. More...
 

Variables

FR_NAME_NUMBER const ldap_scope []
 
FR_NAME_NUMBER const ldap_supported_extensions []
 
FR_NAME_NUMBER const ldap_tls_require_cert []
 

Detailed Description

LDAP authorization and authentication module headers.

Id:
33da9d0a84ca802c4567cb2b4b1c443c3650155c
Author
Arran Cudbard-Bell a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg

Definition in file ldap.h.


Data Structure Documentation

struct ldap_acct_section

Definition at line 136 of file ldap.h.

+ Collaboration diagram for ldap_acct_section:
Data Fields
CONF_SECTION * cs Section configuration.
char const * reference Configuration reference string.
struct ldap_handle

Tracks the state of a libldap connection handle.

Definition at line 163 of file ldap.h.

+ Collaboration diagram for ldap_handle:
Data Fields
rlm_ldap_control_t clientctrls[LDAP_MAX_CONTROLS+1] Client controls to use for all operations with this handle.
int clientctrls_cnt Number of client controls associated with the handle.
LDAP * handle libldap handle.
rlm_ldap_t * inst rlm_ldap configuration.
bool rebound Whether the connection has been rebound to something other than the admin user.
bool referred Whether the connection is now established a server other than the configured one.
rlm_ldap_control_t serverctrls[LDAP_MAX_CONTROLS+1] Server controls to use for all operations with this handle.
int serverctrls_cnt Number of server controls associated with the handle.
struct ldap_instance

Definition at line 180 of file ldap.h.

+ Collaboration diagram for ldap_instance:
Data Fields
bool access_positive If true the presence of the attribute will allow access, else it will deny access.
ldap_acct_section_t * accounting Modify mappings for accounting.
char const * admin_identity Identity we bind as when we need to query the LDAP directory.
char const * admin_password Password used in administrative bind.
ldap_sasl admin_sasl SASL parameters used when binding as the admin.
char const * cache_attribute Sets the attribute we use when creating and retrieving cached group memberships.
fr_dict_attr_t const * cache_da The DA associated with this specific instance of the.

rlm_ldap module.

bool cacheable_group_dn If true the server will determine complete set of group memberships for the current user object, and perform any resolution necessary to determine the DNs of those groups, then right them to the control list (LDAP-GroupDN).
bool cacheable_group_name If true the server will determine complete set of group memberships for the current user object, and perform any resolution necessary to determine the names of those groups, then right them to the control list (LDAP-Group).
bool chase_referrals If the LDAP server returns a referral to another server or point in the tree, follow it, establishing new connections and binding where necessary.
bool chase_referrals_unset If true, use the OpenLDAP defaults for chase_referrals.
char const * clientobj_base_dn DN to search for clients under.
char const * clientobj_filter Filter to retrieve only client objects.
int clientobj_scope Search scope.
char const * clientobj_scope_str Scope (sub, one, base).
char const * config_server Server set in the config.
CONF_SECTION * cs Main configuration section for this instance.
vp_tmpl_t * default_profile If this is set, we will search for a profile object with this name, and map any attributes it contains.

No value should be set if profiles are not being used as there is an associated performance penalty.

int dereference libldap value specifying dereferencing behaviour.
char const * dereference_str When to dereference (never, searching, finding, always)
bool do_clients If true, attempt to load clients on instantiation.
bool expect_password True if the user_map included a mapping between an LDAP attribute and one of our password reference attributes.
char const * group_attribute Sets the attribute we use when comparing group group memberships.
fr_dict_attr_t const * group_da The DA associated with this specific instance of the.

rlm_ldap module.

vp_tmpl_t * groupobj_base_dn DN to search for users under.
char const * groupobj_filter Filter to retrieve only group objects.
char const * groupobj_membership_filter Filter to only retrieve groups which contain the user as a member.
char const * groupobj_name_attr The name of the group.
int groupobj_scope Search scope.
char const * groupobj_scope_str Scope (sub, one, base).
LDAP * handle Hack for OpenLDAP libldap global initialisation.
uint32_t ldap_debug Debug flag for the SDK.
char const * name Instance name.
fr_connection_pool_t * pool Connection pool instance.
uint16_t port Port to use when binding to the server.
ldap_acct_section_t * postauth Modify mappings for post-auth.
char const * profile_attr Attribute that identifies profiles to apply.

May appear in userobj or groupobj.

vp_tmpl_t * profile_filter Filter to retrieve only retrieve group objects.
bool rebind Controls whether we set an ldad_rebind_proc function and so determines if we can bind to other servers whilst chasing referrals.

If this is false, we will still chase referrals on the same server, but won't bind to other servers.

uint32_t res_timeout How long we wait for a result from the server.
char * server Initial server to bind to.
uint32_t srv_timelimit How long the server should spent on a single request (also bounded by value on the server).
bool start_tls Send the Start TLS message to the LDAP directory to start encrypted communications using the standard LDAP port.
char const * tls_ca_file Sets the full path to a CA certificate (used to validate the certificate the server presents).
char const * tls_ca_path Sets the path to a directory containing CA certificates.
char const * tls_certificate_file Sets the path to the public certificate file we present to the servers.
int tls_mode
char const * tls_private_key_file Sets the path to the private key for our public certificate.
char const * tls_random_file Path to the random file if /dev/random and /dev/urandom are unavailable.
int tls_require_cert OpenLDAP constant representing the require cert string.
char const * tls_require_cert_str Sets requirements for validating the certificate the server presents.
bool use_referral_credentials If true use credentials from the referral URL.
vp_map_t * user_map Attribute map applied to users and profiles.
ldap_sasl_dynamic user_sasl SASL parameters used when binding as the user.
char const * userobj_access_attr Attribute to check to see if the user should be locked out.
vp_tmpl_t * userobj_base_dn DN to search for users under.
vp_tmpl_t * userobj_filter Filter to retrieve only user objects.
char const * userobj_membership_attr Attribute that describes groups the user is a member of.
int userobj_scope Search scope.
char const * userobj_scope_str Scope (sub, one, base).
char const * userobj_sort_by List of attributes to sort by.
LDAPControl * userobj_sort_ctrl Server side sort control.
char const * valuepair_attr Generic dynamic mapping attribute, contains a RADIUS attribute and value.
struct ldap_sasl

Definition at line 142 of file ldap.h.

Data Fields
char const * mech SASL mech(s) to try.
char const * proxy Identity to proxy.
char const * realm Kerberos realm.
struct ldap_sasl_dynamic

Definition at line 148 of file ldap.h.

+ Collaboration diagram for ldap_sasl_dynamic:
Data Fields
vp_tmpl_t * mech SASL mech(s) to try.
vp_tmpl_t * proxy Identity to proxy.
vp_tmpl_t * realm Kerberos realm.
struct rlm_ldap_control

Definition at line 154 of file ldap.h.

Data Fields
LDAPControl * control LDAP control.
bool freeit Whether the control should be freed after we've finished using it.
struct rlm_ldap_map_exp

Result of expanding the RHS of a set of maps.

Used to store the array of attributes we'll be querying for.

Definition at line 375 of file ldap.h.

+ Collaboration diagram for rlm_ldap_map_exp:
Data Fields
char const * attrs[LDAP_MAX_ATTRMAP+LDAP_MAP_RESERVED+1] Reserve some space for access attributes.

and NULL termination.

int count Index on next free element.
TALLOC_CTX * ctx Context to allocate new attributes in.
vp_map_t const * maps Head of list of maps we expanded the RHS of.
struct rlm_ldap_result

Contains a collection of values.

Definition at line 386 of file ldap.h.

Data Fields
int count Number of values.
struct berval ** values libldap struct containing bv_val (char *) and length bv_len.

Macro Definition Documentation

#define LDAP_DBG (   fmt,
  ... 
)    radlog(L_DBG, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)

Definition at line 426 of file ldap.h.

#define LDAP_DBG2 (   fmt,
  ... 
)    if (rad_debug_lvl >= L_DBG_LVL_2) radlog(L_DBG, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)

Definition at line 429 of file ldap.h.

#define LDAP_DBG3 (   fmt,
  ... 
)    if (rad_debug_lvl >= L_DBG_LVL_3) radlog(L_DBG, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)

Definition at line 432 of file ldap.h.

#define LDAP_DBG_REQ (   fmt,
  ... 
)    do { if (request) {RDEBUG(fmt, ##__VA_ARGS__);} else {LDAP_DBG(fmt, ##__VA_ARGS__);}} while (0)

Definition at line 427 of file ldap.h.

#define LDAP_DBG_REQ2 (   fmt,
  ... 
)    do { if (request) {RDEBUG2(fmt, ##__VA_ARGS__);} else if (rad_debug_lvl >= L_DBG_LVL_2) {LDAP_DBG(fmt, ##__VA_ARGS__);}} while (0)

Definition at line 430 of file ldap.h.

#define LDAP_DBG_REQ3 (   fmt,
  ... 
)    do { if (request) {RDEBUG3(fmt, ##__VA_ARGS__);} else if (rad_debug_lvl >= L_DBG_LVL_3) {LDAP_DBG(fmt, ##__VA_ARGS__);}} while (0)

Definition at line 433 of file ldap.h.

#define LDAP_DBGW (   fmt,
  ... 
)    radlog(L_DBG_WARN, "rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)

Definition at line 423 of file ldap.h.

#define LDAP_DBGW_REQ (   fmt,
  ... 
)    do { if (request) {RWDEBUG(fmt, ##__VA_ARGS__);} else {LDAP_DBGW(fmt, ##__VA_ARGS__);}} while (0)

Definition at line 424 of file ldap.h.

#define LDAP_DEPRECATED   1

Definition at line 22 of file ldap.h.

#define LDAP_ERR (   fmt,
  ... 
)    ERROR("rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)

Definition at line 435 of file ldap.h.

#define LDAP_ERR_REQ (   fmt,
  ... 
)    do { if (request) {REDEBUG(fmt, ##__VA_ARGS__);} else {LDAP_ERR(fmt, ##__VA_ARGS__);}} while (0)

Definition at line 436 of file ldap.h.

#define LDAP_EXT ( )    if (extra) LDAP_ERR(extra)

Definition at line 438 of file ldap.h.

#define LDAP_EXT_REQ ( )    do { if (extra) { if (request) REDEBUG("%s", extra); else LDAP_ERR("%s", extra); }} while (0)

Definition at line 439 of file ldap.h.

#define LDAP_INFO (   fmt,
  ... 
)    INFO("rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)

Definition at line 420 of file ldap.h.

#define LDAP_MAP_RESERVED   4

Number of additional items to allocate in expanded.

attribute name arrays. Currently for enable attribute, group membership attribute, valuepair attribute, and profile attribute.

Definition at line 109 of file ldap.h.

#define LDAP_MAX_ATTR_STR_LEN   256

Maximum length of an xlat expanded LDAP attribute.

Definition at line 119 of file ldap.h.

#define LDAP_MAX_ATTRMAP   128

Maximum number of mappings between LDAP and.

FreeRADIUS attributes.

Definition at line 107 of file ldap.h.

#define LDAP_MAX_CACHEABLE   64

Maximum number of groups we retrieve from the server for.

a given user. If more than this number are retrieve the module returns invalid.

Definition at line 114 of file ldap.h.

#define LDAP_MAX_CONTROLS   10

Maximum number of client/server controls.

Used to allocate static arrays of control pointers.

Definition at line 105 of file ldap.h.

#define LDAP_MAX_DN_STR_LEN   1024

Maximum length of an xlat expanded DN.

Definition at line 121 of file ldap.h.

#define LDAP_MAX_FILTER_STR_LEN   1024

Maximum length of an xlat expanded filter.

Definition at line 120 of file ldap.h.

#define LDAP_MAX_GROUP_NAME_LEN   128

Maximum name of a group name.

Definition at line 118 of file ldap.h.

#define LDAP_VENDOR_VERSION_PATCH   0

Definition at line 73 of file ldap.h.

#define LDAP_VIRTUAL_DN_ATTR   "dn"

'Virtual' attribute which maps to the DN of the object.

Definition at line 123 of file ldap.h.

#define LDAP_WARN (   fmt,
  ... 
)    WARN("rlm_ldap (%s): " fmt, inst->name, ##__VA_ARGS__)

Definition at line 421 of file ldap.h.

#define MOD_PREFIX   "rlm_ldap"

The name of the module.

Definition at line 103 of file ldap.h.

Typedef Documentation

typedef struct ldap_handle ldap_handle_t

Tracks the state of a libldap connection handle.

typedef struct ldap_sasl ldap_sasl

Result of expanding the RHS of a set of maps.

Used to store the array of attributes we'll be querying for.

Contains a collection of values.

typedef struct ldap_instance rlm_ldap_t

Definition at line 134 of file ldap.h.

Enumeration Type Documentation

Codes returned by rlm_ldap internal functions.

Enumerator
LDAP_PROC_CONTINUE 

Operation is in progress.

LDAP_PROC_SUCCESS 

Operation was successfull.

LDAP_PROC_ERROR 

Unrecoverable library/server error.

LDAP_PROC_RETRY 

Transitory error, caller should retry the operation with a new connection.

LDAP_PROC_NOT_PERMITTED 

Operation was not permitted, either current user was locked out in the case of binds, or has insufficient access.

LDAP_PROC_REJECT 

Bind failed, user was rejected.

LDAP_PROC_BAD_DN 

Specified an invalid object in a bind or search DN.

LDAP_PROC_NO_RESULT 

Got no results.

Definition at line 395 of file ldap.h.

Enumerator
LDAP_EXT_UNSUPPORTED 

Unsupported extension.

LDAP_EXT_BINDNAME 

Specifies the user DN or name for an LDAP bind.

LDAP_EXT_BINDPW 

Specifies the password for an LDAP bind.

Definition at line 126 of file ldap.h.

Function Documentation

char const* edir_errstr ( int  code)

Definition at line 245 of file edir.c.

+ Here is the caller graph for this function:

void* mod_conn_create ( TALLOC_CTX *  ctx,
void *  instance,
struct timeval const *  timeout 
)

Create a new connection pool handle.

Create a new connection to Couchbase within the pool and initialize information associated with the connection instance.

Parameters
ctxThe connection parent context.
instanceThe module instance.
timeoutMaximum time to establish the connection.
Returns
  • New connection handle.
  • NULL on error.

Create a new connection pool handle.

Create a new ldap connection and allocate memory for a new rlm_handle_t

Create a new connection pool handle.

Matches the fr_connection_create_t function prototype, is passed to fr_connection_pool_init, and called when a new connection is required by the connection pool API.

Creates an instances of rlm_rest_handle_t, and rlm_rest_curl_context_t which hold the context data required for generating requests and parsing responses.

If instance->connect_uri is not NULL libcurl will attempt to open a TCP socket to the server specified in the URI. This is done so that when the socket is first used, there will already be a cached TCP connection to the REST server associated with the curl handle.

See Also
fr_connection_pool_init
fr_connection_create_t
connection.c

Create a new connection to Couchbase within the pool and initialize information associated with the connection instance.

Parameters
ctxThe connection parent context.
instanceThe module instance.
timeoutMaximum time to establish the connection.
Returns
  • New connection handle.
  • NULL on error.

Create a new connection pool handle.

Create a new ldap connection and allocate memory for a new rlm_handle_t

Create a new connection pool handle.

Matches the fr_connection_create_t function prototype, is passed to fr_connection_pool_init, and called when a new connection is required by the connection pool API.

Creates an instances of rlm_rest_handle_t, and rlm_rest_curl_context_t which hold the context data required for generating requests and parsing responses.

If instance->connect_uri is not NULL libcurl will attempt to open a TCP socket to the server specified in the URI. This is done so that when the socket is first used, there will already be a cached TCP connection to the REST server associated with the curl handle.

See Also
fr_connection_pool_init
fr_connection_create_t
connection.c

Definition at line 68 of file mod.c.

ldap_handle_t* mod_conn_get ( rlm_ldap_t const *  inst,
REQUEST request 
)
void mod_conn_release ( rlm_ldap_t const *  inst,
ldap_handle_t conn 
)

Frees an LDAP socket back to the connection pool.

If the socket was rebound chasing a referral onto another server then we destroy it. If the socket was rebound to another user on the same server, we let the next caller rebind it.

Parameters
instrlm_ldap configuration.
connto release.

Definition at line 1758 of file ldap.c.

+ Here is the call graph for this function:

int nmasldap_get_password ( LDAP *  ld,
char const *  dn,
char *  password,
size_t *  passlen 
)

Attempt to retrieve the universal password from Novell eDirectory.

Parameters
[in]ldLDAP handle.
[in]dnof user we want to retrieve the password for.
[out]passwordWhere to write the retrieved password.
[out]passlenLength of data written to the password buffer.
Returns
  • 0 on success.
  • < 0 on failure.

Definition at line 165 of file edir.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* rlm_ldap_berval_to_string ( TALLOC_CTX *  ctx,
struct berval const *  in 
)

Convert a berval to a talloced string.

The ldap_get_values function is deprecated, and ldap_get_values_len does not guarantee the berval buffers it returns are \0 terminated.

For some cases this is fine, for others we require a \0 terminated buffer (feeding DNs back into libldap for example).

Parameters
ctxto allocate in.
inBerval to copy.
Returns
\0 terminated buffer containing in->bv_val.

Definition at line 281 of file ldap.c.

+ Here is the caller graph for this function:

ldap_rcode_t rlm_ldap_bind ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t **  pconn,
char const *  dn,
char const *  password,
ldap_sasl sasl,
bool  retry,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls 
)

Bind to the LDAP directory as a user.

Performs a simple bind to the LDAP directory, and handles any errors that occur.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request, this may be NULL, in which case all debug logging is done with radlog.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
[in]dnof the user, may be NULL to bind anonymously.
[in]passwordof the user, may be NULL if no password is specified.
[in]saslmechanism to use for bind, and additional parameters.
[in]retryif the server is down.
[in]serverctrlsSearch controls to pass to the server. Only used for SASL binds. May be NULL.
[in]clientctrlsSearch controls for sasl_bind. Only used for SASL binds. May be NULL.
Returns
One of the LDAP_PROC_* (ldap_rcode_t) values.

Definition at line 751 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t rlm_ldap_cacheable_groupobj ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t **  pconn 
)

Convert group membership information into attributes.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
Returns
One of the RLM_MODULE_* values.

Definition at line 415 of file groups.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t rlm_ldap_cacheable_userobj ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t **  pconn,
LDAPMessage *  entry,
char const *  attr 
)

Convert group membership information into attributes.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
[in]entryretrieved by rlm_ldap_find_user or rlm_ldap_search.
[in]attrmembership attribute to look for in the entry.
Returns
One of the RLM_MODULE_* values.

Definition at line 267 of file groups.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t rlm_ldap_check_access ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t const *  conn,
LDAPMessage *  entry 
)

Check for presence of access attribute in result.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in]connused to retrieve access attributes.
[in]entryretrieved by rlm_ldap_find_user or rlm_ldap_search.
Returns

Definition at line 1327 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t rlm_ldap_check_cached ( rlm_ldap_t const *  inst,
REQUEST request,
VALUE_PAIR check 
)

Check group membership attributes to see if a user is a member.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in]checkvp containing the group value (name or dn).
Returns
One of the RLM_MODULE_* values.

Definition at line 812 of file groups.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t rlm_ldap_check_groupobj_dynamic ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t **  pconn,
VALUE_PAIR check 
)

Query the LDAP directory to check if a group object includes a user object as a member.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
[in]checkvp containing the group value (name or dn).
Returns
One of the RLM_MODULE_* values.

Definition at line 530 of file groups.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rlm_ldap_check_reply ( rlm_ldap_t const *  inst,
REQUEST request 
)

Verify we got a password from the search.

Checks to see if after the LDAP to RADIUS mapping has been completed that a reference password.

Parameters
instrlm_ldap configuration.
requestCurrent request.

Definition at line 1362 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t rlm_ldap_check_userobj_dynamic ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t **  pconn,
char const *  dn,
VALUE_PAIR check 
)

Query the LDAP directory to check if a user object is a member of a group.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
[in]dnof user object.
[in]checkvp containing the group value (name or dn).
Returns
One of the RLM_MODULE_* values.

Definition at line 632 of file groups.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rlm_ldap_client_load ( rlm_ldap_t const *  inst,
CONF_SECTION tmpl,
CONF_SECTION map 
)

Load clients from LDAP on server start.

Parameters
[in]instrlm_ldap configuration.
[in]tmplto use as the base for the new client.
[in]mapto load client attribute/LDAP attribute mappings from.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 102 of file clients.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rlm_ldap_control_add_client ( ldap_handle_t conn,
LDAPControl *  ctrl,
bool  freeit 
)

Add a clientctrl to a connection handle.

All internal LDAP functions will pass this clientctrl to libldap.

Parameters
connto add control to.
ctrlto add.
freeitWhether the control should be freed when the handle is released or closed.
Returns
  • 0 on success.
  • -1 on failure (exceeded maximum controls).

Definition at line 110 of file control.c.

int rlm_ldap_control_add_server ( ldap_handle_t conn,
LDAPControl *  ctrl,
bool  freeit 
)

Add a serverctrl to a connection handle.

All internal LDAP functions will pass this serverctrl to the server.

Parameters
connto add control to.
ctrlto add.
freeitWhether the control should be freed when the handle is released or closed.
Returns
  • 0 on success.
  • -1 on failure (exceeded maximum controls).

Definition at line 86 of file control.c.

int rlm_ldap_control_add_session_tracking ( ldap_handle_t conn,
REQUEST request 
)

+ Here is the caller graph for this function:

void rlm_ldap_control_clear ( ldap_handle_t conn)

Clear and free any controls associated with a connection.

Parameters
connto clear controls from.

Definition at line 127 of file control.c.

+ Here is the caller graph for this function:

void rlm_ldap_control_merge ( LDAPControl *  serverctrls_out[],
LDAPControl *  clientctrls_out[],
size_t  serverctrls_len,
size_t  clientctrls_len,
ldap_handle_t conn,
LDAPControl *  serverctrls_in[],
LDAPControl *  clientctrls_in[] 
)

Merge connection and call specific client and server controls.

LDAP_OPT_CLIENT_CONTROLS and LDAP_OPT_SERVER_CONTROLS are useless because they're overriden in their entirety if any call specific controls are specified.

Parameters
[out]serverctrls_outWhere to write serverctrls.
[out]clientctrls_outWhere to write clientctrls.
[in]serverctrls_lenlength of serverctrls array.
[in]clientctrls_lenlength of clientctrls array.
[in]connto get controls from.
[in]serverctrls_infrom arguments.
[in]clientctrls_infrom_arguments.

Definition at line 41 of file control.c.

+ Here is the caller graph for this function:

char const* rlm_ldap_error_str ( ldap_handle_t const *  conn)

Return the error string associated with a handle.

Parameters
connto retrieve error from.
Returns
error string.

Definition at line 488 of file ldap.c.

+ Here is the caller graph for this function:

size_t rlm_ldap_escape_func ( UNUSED REQUEST request,
char *  out,
size_t  outlen,
char const *  in,
UNUSED void *  arg 
)

Converts "bad" strings into ones which are safe for LDAP.

Note
RFC 4515 says filter strings can only use the
\<hex><hex> 
format, whereas RFC 4514 indicates that some chars in DNs, may be escaped simply with a backslash. For simplicity, we always use the hex escape sequences. In other areas where we're doing DN comparison, the DNs need to be normalised first so that they both use only hex escape sequences.
This is a callback for xlat operations.

Will escape any characters in input strings that would cause the string to be interpreted as part of a DN and or filter. Escape sequence is

\<hex><hex> 

.

Parameters
requestThe current request.
outPointer to output buffer.
outlenSize of the output buffer.
inRaw unescaped string.
argAny additional arguments (unused).

Definition at line 65 of file ldap.c.

+ Here is the caller graph for this function:

char const* rlm_ldap_find_user ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t **  pconn,
char const *  attrs[],
bool  force,
LDAPMessage **  result,
rlm_rcode_t rcode 
)

Retrieve the DN of a user object.

Retrieves the DN of a user and adds it to the control list as LDAP-UserDN. Will also retrieve any attributes passed and return the result in *result.

This potentially allows for all authorization and authentication checks to be performed in one ldap search operation, which is a big bonus given the number of crappy, slow cough*AD*cough LDAP directory servers out there.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
[in]attrsAdditional attributes to retrieve, may be NULL.
[in]forceQuery even if the User-DN already exists.
[out]resultWhere to write the result, may be NULL in which case result is discarded.
[out]rcodeThe status of the operation, one of the RLM_MODULE_* codes.
Returns
The user's DN or NULL on error.

< Whether the message should be freed after being processed.

Definition at line 1152 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool rlm_ldap_is_dn ( char const *  in,
size_t  inlen 
)

Check whether a string looks like a DN.

Parameters
[in]inStr to check.
[in]inlenLength of string to check.
Returns
  • true if string looks like a DN.
  • false if string does not look like DN.

Definition at line 168 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rlm_ldap_map_do ( const rlm_ldap_t inst,
REQUEST request,
LDAP *  handle,
rlm_ldap_map_exp_t const *  expanded,
LDAPMessage *  entry 
)

Convert attribute map into valuepairs.

Use the attribute map built earlier to convert LDAP values into valuepairs and insert them into whichever list they need to go into.

This is NOT atomic, but there's no condition for which we should error out...

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in]handleassociated with entry.
[in]expandedattributes (rhs of map).
[in]entryto retrieve attributes from.
Returns
  • Number of maps successfully applied.
  • -1 on failure.

Definition at line 302 of file attrmap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rlm_ldap_map_expand ( rlm_ldap_map_exp_t expanded,
REQUEST request,
vp_map_t const *  maps 
)

Expand values in an attribute map where needed.

Parameters
[out]expandedarray of attributes. Need not be initialised (we'll initialise).
[in]requestThe current request.
[in]mapsto expand.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 251 of file attrmap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rlm_ldap_map_getvalue ( TALLOC_CTX *  ctx,
VALUE_PAIR **  out,
REQUEST request,
vp_map_t const *  map,
void *  uctx 
)

Callback for map_to_request.

Performs exactly the same job as map_to_vp, but pulls attribute values from LDAP entries

See Also
map_to_vp

Definition at line 36 of file attrmap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int rlm_ldap_map_verify ( vp_map_t map,
void *  instance 
)

Definition at line 146 of file attrmap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ldap_rcode_t rlm_ldap_modify ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t **  pconn,
char const *  dn,
LDAPMod *  mods[],
LDAPControl **  serverctrls,
LDAPControl **  clientctrls 
)

Modify something in the LDAP directory.

Binds as the administrative user and attempts to modify an LDAP object.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
[in]dnof the object to modify.
[in]modsto make, see 'man ldap_modify' for more information.
[in]serverctrlsSearch controls to pass to the server. May be NULL.
[in]clientctrlsSearch controls for ldap_modify. May be NULL.
Returns
One of the LDAP_PROC_* (ldap_rcode_t) values.

Definition at line 1048 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t rlm_ldap_normalise_dn ( char *  out,
char const *  in 
)

Normalise escape sequences in a DN.

Characters in a DN can either be escaped as

\<hex><hex> 

or

\<special> 

The LDAP directory chooses how characters are escaped, which can make local comparisons of DNs difficult.

Here we search for hex sequences that match special chars, and convert them to the

\<special> 

form.

Note
the resulting output string will only ever be shorter than the input, so it's fine to use the same buffer for both out and in.
Parameters
outWhere to write the normalised DN.
inThe input DN.
Returns
The number of bytes written to out.

Definition at line 312 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ldap_rcode_t rlm_ldap_result ( rlm_ldap_t const *  inst,
ldap_handle_t const *  conn,
int  msgid,
char const *  dn,
LDAPMessage **  result,
char const **  error,
char **  extra 
)

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.

Parameters
[in]instof LDAP module.
[in]connCurrent connection.
[in]msgidreturned from last operation. May be -1 if no result processing is required.
[in]dnLast search or bind DN.
[out]resultWhere to write result, if NULL result will be freed.
[out]errorWhere to write the error string, may be NULL, must not be freed.
[out]extraWhere to write additional error string to, may be NULL (faster) or must be freed (with talloc_free).
Returns
One of the LDAP_PROC_* (ldap_rcode_t) values.

Definition at line 517 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ldap_rcode_t rlm_ldap_sasl_interactive ( rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_t conn,
char const *  identity,
char const *  password,
ldap_sasl sasl,
LDAPControl **  serverctrls,
LDAPControl **  clientctrls,
char const **  error,
char **  extra 
)

Initiate an LDAP interactive bind.

Parameters
[in]instrlm_ldap configuration.
[in]requestCurrent request, this may be NULL, in which case all debug logging is done with radlog.
[in]connto use. May change as this function calls functions which auto re-connect.
[in]identityof the user.
[in]passwordof the user.
[in]saslmechanism to use for bind, and additional parameters.
[in]serverctrlsSearch controls to pass to the server. May be NULL.
[in]clientctrlsSearch controls for ldap_sasl_interactive. May be NULL.
[out]errormessage resulting from bind.
[out]extrainformation about the error.
Returns
One of the LDAP_PROC_* (ldap_rcode_t) values.

Definition at line 105 of file sasl.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ldap_rcode_t rlm_ldap_search ( LDAPMessage **  result,
rlm_ldap_t const *  inst,
REQUEST request,
ldap_handle_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.

Binds as the administrative user and performs a search, dealing with any errors.

Parameters
[out]resultWhere to store the result. Must be freed with ldap_msgfree if LDAP_PROC_SUCCESS is returned. May be NULL in which case result will be automatically freed after use.
[in]instrlm_ldap configuration.
[in]requestCurrent request.
[in,out]pconnto use. May change as this function calls functions which auto re-connect.
[in]dnto use as base for the search.
[in]scopeto use (LDAP_SCOPE_BASE, LDAP_SCOPE_ONE, LDAP_SCOPE_SUB).
[in]filterto use, should be pre-escaped.
[in]attrsto retrieve.
[in]serverctrlsSearch controls to pass to the server. May be NULL.
[in]clientctrlsSearch controls for ldap_search. May be NULL.
Returns
One of the LDAP_PROC_* (ldap_rcode_t) values.

Definition at line 880 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t rlm_ldap_unescape_func ( UNUSED REQUEST request,
char *  out,
size_t  outlen,
char const *  in,
UNUSED void *  arg 
)

Converts escaped DNs and filter strings into normal.

Note
RFC 4515 says filter strings can only use the
\<hex><hex> 
format, whereas RFC 4514 indicates that some chars in DNs, may be escaped simply with a backslash..

Will unescape any special characters in strings, or

\<hex><hex> 

sequences.

Parameters
requestThe current request.
outPointer to output buffer.
outlenSize of the output buffer.
inEscaped string string.
argAny additional arguments (unused).

Definition at line 121 of file ldap.c.

+ Here is the caller graph for this function:

ssize_t rlm_ldap_xlat_filter ( REQUEST request,
char const **  sub,
size_t  sublen,
char *  out,
size_t  outlen 
)

Combine and expand filters.

Parameters
requestCurrent request.
outWhere to write the expanded string.
outlenLength of output buffer.
subArray of subfilters (may contain NULLs).
sublenNumber of potential subfilters in array.
Returns
length of expanded data.

Definition at line 416 of file ldap.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

FR_NAME_NUMBER const ldap_scope[]

Definition at line 44 of file rlm_ldap.c.

FR_NAME_NUMBER const ldap_supported_extensions[]

Definition at line 39 of file ldap.c.

FR_NAME_NUMBER const ldap_tls_require_cert[]