The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rlm_ldap.h
Go to the documentation of this file.
1#pragma once
2/**
3 * $Id: d86c176a43a8c47683e1f1d6dbbdb6c8bcf16142 $
4 * @file rlm_ldap.h
5 * @brief LDAP authorization and authentication module headers.
6 *
7 * @note Do not rename to ldap.h. This causes configure checks to break
8 * in stupid ways, where the configure script will use the local ldap.h
9 * file, instead of the one from libldap.
10 *
11 * @author Arran Cudbard-Bell (a.cudbardb@freeradius.org)
12 * @copyright 2015 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
13 * @copyright 2013 Network RADIUS SAS (legal@networkradius.com)
14 * @copyright 2013-2015 The FreeRADIUS Server Project.
15 */
16#include <freeradius-devel/server/base.h>
17#include <freeradius-devel/server/module_rlm.h>
18#include <freeradius-devel/ldap/base.h>
19
20typedef struct {
21 /*
22 * Options
23 */
24#ifdef LDAP_CONTROL_X_SESSION_TRACKING
25 bool session_tracking; //!< Whether we add session tracking controls, which help
26 //!< identify the autz or acct session the commands were
27 //!< issued for.
28#endif
29 struct {
30 /*
31 * User object attributes and filters
32 */
33 char const *obj_sort_by; //!< List of attributes to sort by.
34 LDAPControl *obj_sort_ctrl; //!< Server side sort control.
35
36 int obj_scope; //!< Search scope.
37
38 char const *obj_access_attr; //!< Attribute to check to see if the user should be locked out.
39 bool access_positive; //!< If true the presence of the attribute will allow access,
40 //!< else it will deny access.
41
42 char const *access_value_negate; //!< If the value of the access_attr matches this, the result
43 ///< will be negated.
44 char const *access_value_suspend; //!< Value that indicates suspension. Is not affected by
45 ///< access_positive and will always allow access, but will apply
46 ///< a different profile.
47 bool expect_password; //!< Allow the user to forcefully decide if a password should be
48 ///< expected. Controls whether warnings are issued.
49 bool expect_password_is_set; //!< Whether an expect password value was provided.
50
51 char const *dn_attr_str; //!< Sets the attribute we use when creating and retrieving
52 //!< cached group memberships.
53
54 fr_dict_attr_t const *da; //!< The DA associated with this specific instance of the
55 //!< rlm_ldap module for caching user DNs between autz and
56 ///< auth phases.
57 } user;
58
59 /*
60 * Group object attributes and filters
61 */
62 struct {
63 char const *userobj_membership_attr; //!< Attribute that describes groups the user is a member of.
64
65 char const *obj_filter; //!< Filter to retrieve only group objects.
66 int obj_scope; //!< Search scope.
67
68 char const *obj_name_attr; //!< The name of the group.
69 char const *obj_membership_filter; //!< Filter to only retrieve groups which contain
70 //!< the user as a member.
71
72 bool cacheable_name; //!< If true the server will determine complete set of group
73 //!< memberships for the current user object, and perform any
74 //!< resolution necessary to determine the names of those
75 //!< groups, then right them to the control list (LDAP-Group).
76
77 bool cacheable_dn; //!< If true the server will determine complete set of group
78 //!< memberships for the current user object, and perform any
79 //!< resolution necessary to determine the DNs of those groups,
80 //!< then right them to the control list (LDAP-GroupDN).
81
82 char const *cache_attr_str; //!< Sets the attribute we use when creating and retrieving
83 //!< cached group memberships.
84
85 fr_dict_attr_t const *cache_da; //!< The DA associated with this specific instance of the
86 //!< rlm_ldap module.
87
88 char const *attribute; //!< Sets the attribute we use when comparing group
89 //!< group memberships.
90
91 fr_dict_attr_t const *da; //!< The DA associated with this specific instance of the
92 //!< rlm_ldap module.
93
94 bool allow_dangling_refs; //!< Don't error if we fail to resolve a group DN referenced
95 ///< from a user object.
96
97 bool skip_on_suspend; //!< Don't process groups if the user is suspended.
98 } group;
99
100 char const *valuepair_attr; //!< Generic dynamic mapping attribute, contains a RADIUS
101 //!< attribute and value.
102
103 /*
104 * Profiles
105 */
106 struct {
107 int obj_scope; //!< Search scope.
108 char const *attr; //!< Attribute that identifies profiles to apply. May appear
109 //!< in userobj or groupobj.
110 char const *attr_suspend; //!< Attribute that identifies profiles to apply when the user's
111 ///< account is suspended. May appear in userobj or groupobj.
112 char const *obj_sort_by; //!< List of attributes to sort profiles by
113 LDAPControl *obj_sort_ctrl; //!< Server side sort control
114 char const *check_attr; //!< LDAP attribute containing check conditions to determine if
115 //!< the profile should be applied
116 char const *fallthrough_attr; //!< LDAP attribute containing conditions to determine if
117 ///< processing should continue to the next profile when more
118 ///< than one is returned.
119 bool fallthrough_def; //!< Should profile processing fall through by default.
120 } profile;
121
122#ifdef WITH_EDIR
123 /*
124 * eDir support
125 */
126 bool edir; //!< If true attempt to retrieve the user's cleartext password
127 //!< using the Universal Password feature of Novell eDirectory.
128 bool edir_autz; //!< If true, and we have the Universal Password, bind with it
129 //!< to perform additional authorisation checks.
130#endif
131
132 fr_ldap_config_t handle_config; //!< Connection configuration instance.
133 trunk_conf_t trunk_conf; //!< Trunk configuration
134 trunk_conf_t bind_trunk_conf; //!< Trunk configuration for trunk used for bind auths
135
136 module_instance_t const *mi; //!< Module instance data for thread lookups.
137
138 fr_pair_list_t *trigger_args; //!< Pairs passed to trigger request for standard trunk.
139 fr_pair_list_t *bind_trigger_args; //!< Pairs passed to trigger request for bind trunk.
140} rlm_ldap_t;
141
142/** Call environment used in LDAP authorization
143 *
144 */
145typedef struct {
146 fr_value_box_t user_base; //!< Base DN in which to search for users.
147 fr_value_box_t user_filter; //!< Filter to use when searching for users.
148 fr_value_box_t group_base; //!< Base DN in which to search for groups.
149 tmpl_t *group_filter; //!< tmpl to expand as group membership filter.
150 fr_value_box_t default_profile; //!< If this is set, we will search for a profile object
151 //!< with this name, and map any attributes it contains.
152 //!< No value should be set if profiles are not being used
153 //!< as there is an associated performance penalty.
154 fr_value_box_t profile_filter; //!< Filter to use when searching for profiles.
155
156 map_list_t *user_map; //!< Attribute map applied to users and profiles.
157
158 fr_value_box_t const *expect_password; //!< True if the user_map included a mapping between an LDAP
159 //!< attribute and one of our password reference attributes.
161
162/** Call environment used in group membership xlat
163 *
164 */
165typedef struct {
166 fr_value_box_t user_base; //!< Base DN in which to search for users.
167 fr_value_box_t user_filter; //!< Filter to use when searching for users.
168 fr_value_box_t group_base; //!< Base DN in which to search for groups.
169 tmpl_t *group_filter; //!< tmpl to expand as group membership filter.
171
172/** State list for resumption of authorization
173 *
174 */
188
189/** User's access state
190 *
191 */
192typedef enum {
193 LDAP_ACCESS_ALLOWED = 0, //!< User is allowed to login.
194 LDAP_ACCESS_DISALLOWED, //!< User it not allow to login (disabled)
195 LDAP_ACCESS_SUSPENDED //!< User account has been suspended.
197
198/** Holds state of in progress async authorization
199 *
200 */
217
218/** State list for xlat evaluation of LDAP group membership
219 */
225
226/** Holds state of in progress group membership check xlat
227 *
228 */
244
250
253
254/*
255 * user.c - User lookup functions
256 */
257static inline char const *rlm_find_user_dn_cached(rlm_ldap_t const *inst, request_t *request)
258{
259 fr_pair_t *vp;
260
261 vp = fr_pair_find_by_da(&request->control_pairs, NULL, inst->user.da);
262 if (!vp) return NULL;
263
264 RDEBUG2("Using user DN from request \"%pV\"", &vp->data);
265 return vp->vp_strvalue;
266}
267
269 unlang_result_t *p_result,
270 rlm_ldap_t const *inst, request_t *request,
271 fr_value_box_t *base, fr_value_box_t *filter_box,
272 fr_ldap_thread_trunk_t *ttrunk, char const *attrs[],
273 fr_ldap_query_t **query_out);
274
275ldap_access_state_t rlm_ldap_check_access(rlm_ldap_t const *inst, request_t *request, LDAPMessage *entry);
276
277void rlm_ldap_check_reply(request_t *request, rlm_ldap_t const *inst, char const *inst_name, bool expect_password, fr_ldap_thread_trunk_t const *ttrunk);
278
279/*
280 * groups.c - Group membership functions.
281 */
283 char const *attr);
284
286
289
292
294 rlm_ldap_t const *inst, request_t *request, fr_value_box_t const *check);
295
297 rlm_ldap_t const *inst, request_t *request, fr_ldap_thread_trunk_t *ttrunk,
298 char const *dn, int scope, char const *filter, fr_ldap_map_exp_t const *expanded);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
#define HIDDEN
Definition build.h:316
fr_ldap_result_code_t
LDAP query result codes.
Definition base.h:188
Connection configuration.
Definition base.h:221
Result of expanding the RHS of a set of maps.
Definition base.h:370
LDAP query structure.
Definition base.h:424
Thread LDAP trunk structure.
Definition base.h:401
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
Definition pair.c:703
#define RDEBUG2(fmt,...)
Definition radclient.h:54
rlm_rcode_t
Return codes indicating the result of the module call.
Definition rcode.h:40
ldap_xlat_memberof_call_env_t * env_data
Definition rlm_ldap.h:232
fr_value_box_t * basedn
Definition rlm_ldap.h:237
fr_ldap_map_exp_t expanded
Definition rlm_ldap.h:204
unlang_action_t rlm_ldap_cacheable_groupobj(unlang_result_t *p_result, request_t *request, ldap_autz_ctx_t *autz_ctx)
Convert group membership information into attributes.
Definition groups.c:698
HIDDEN fr_dict_attr_t const * attr_password
Definition rlm_ldap.c:327
fr_value_box_t * filter
Definition rlm_ldap.h:236
fr_pair_list_t * bind_trigger_args
Pairs passed to trigger request for bind trunk.
Definition rlm_ldap.h:139
ldap_autz_call_env_t * call_env
Definition rlm_ldap.h:207
struct berval ** profile_values
Definition rlm_ldap.h:210
HIDDEN fr_dict_attr_t const * attr_crypt_password
Definition rlm_ldap.c:329
unlang_result_t result
Definition rlm_ldap.h:241
ldap_access_state_t
User's access state.
Definition rlm_ldap.h:192
@ LDAP_ACCESS_SUSPENDED
User account has been suspended.
Definition rlm_ldap.h:195
@ LDAP_ACCESS_ALLOWED
User is allowed to login.
Definition rlm_ldap.h:193
@ LDAP_ACCESS_DISALLOWED
User it not allow to login (disabled)
Definition rlm_ldap.h:194
unlang_action_t rlm_ldap_check_groupobj_dynamic(unlang_result_t *p_result, request_t *request, ldap_group_xlat_ctx_t *xlat_ctx)
Initiate an LDAP search to determine group membership, querying group objects.
Definition groups.c:787
unlang_action_t rlm_ldap_map_profile(fr_ldap_result_code_t *ret, int *applied, rlm_ldap_t const *inst, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *dn, int scope, char const *filter, fr_ldap_map_exp_t const *expanded)
Search for and apply an LDAP profile.
Definition profile.c:212
fr_ldap_thread_trunk_t * ttrunk
Definition rlm_ldap.h:206
HIDDEN fr_dict_attr_t const * attr_user_name
Definition base.c:104
fr_ldap_query_t * query
Definition rlm_ldap.h:239
rlm_ldap_t const * inst
Definition rlm_ldap.h:203
fr_value_box_t profile_filter
Filter to use when searching for profiles.
Definition rlm_ldap.h:154
fr_value_box_t user_filter
Filter to use when searching for users.
Definition rlm_ldap.h:147
unlang_action_t rlm_ldap_cacheable_userobj(unlang_result_t *p_result, request_t *request, ldap_autz_ctx_t *autz_ctx, char const *attr)
Convert group membership information into attributes.
Definition groups.c:441
tmpl_t * group_filter
tmpl to expand as group membership filter.
Definition rlm_ldap.h:149
trunk_conf_t bind_trunk_conf
Trunk configuration for trunk used for bind auths.
Definition rlm_ldap.h:134
LDAPMessage * entry
Definition rlm_ldap.h:208
HIDDEN fr_dict_attr_t const * attr_nt_password
Definition rlm_ldap.c:330
ldap_autz_status_t
State list for resumption of authorization.
Definition rlm_ldap.h:175
@ LDAP_AUTZ_GROUP
Definition rlm_ldap.h:177
@ LDAP_AUTZ_FIND
Definition rlm_ldap.h:176
@ LDAP_AUTZ_DEFAULT_PROFILE
Definition rlm_ldap.h:184
@ LDAP_AUTZ_USER_PROFILE
Definition rlm_ldap.h:186
@ LDAP_AUTZ_MAP
Definition rlm_ldap.h:183
@ LDAP_AUTZ_POST_DEFAULT_PROFILE
Definition rlm_ldap.h:185
@ LDAP_AUTZ_POST_GROUP
Definition rlm_ldap.h:178
fr_value_box_t * group
Definition rlm_ldap.h:231
ldap_autz_status_t status
Definition rlm_ldap.h:209
char const * valuepair_attr
Generic dynamic mapping attribute, contains a RADIUS attribute and value.
Definition rlm_ldap.h:100
fr_ldap_query_t * query
Definition rlm_ldap.h:205
unlang_action_t rlm_ldap_check_userobj_dynamic(unlang_result_t *p_result, request_t *request, ldap_group_xlat_ctx_t *xlat_ctx)
Query the LDAP directory to check if a user object is a member of a group.
Definition groups.c:1138
char * profile_value
Definition rlm_ldap.h:212
fr_value_box_t user_base
Base DN in which to search for users.
Definition rlm_ldap.h:166
rlm_ldap_t const * inst
Definition rlm_ldap.h:230
fr_ldap_config_t handle_config
Connection configuration instance.
Definition rlm_ldap.h:132
HIDDEN fr_dict_attr_t const * attr_user_password
Definition rlm_yubikey.c:64
ldap_group_xlat_status_t status
Definition rlm_ldap.h:240
tmpl_t * group_filter
tmpl to expand as group membership filter.
Definition rlm_ldap.h:169
fr_value_box_t group_base
Base DN in which to search for groups.
Definition rlm_ldap.h:148
ldap_access_state_t access_state
What state a user's account is in.
Definition rlm_ldap.h:214
unlang_action_t rlm_ldap_find_user_async(TALLOC_CTX *ctx, unlang_result_t *p_result, rlm_ldap_t const *inst, request_t *request, fr_value_box_t *base, fr_value_box_t *filter_box, fr_ldap_thread_trunk_t *ttrunk, char const *attrs[], fr_ldap_query_t **query_out)
Initiate asynchronous retrieval of the DN of a user object.
Definition user.c:166
fr_value_box_t user_base
Base DN in which to search for users.
Definition rlm_ldap.h:146
HIDDEN fr_dict_attr_t const * attr_password_with_header
Definition rlm_ldap.c:331
fr_ldap_thread_trunk_t * ttrunk
Definition rlm_ldap.h:238
fr_value_box_t group_base
Base DN in which to search for groups.
Definition rlm_ldap.h:168
char const * dn
Definition rlm_ldap.h:213
map_list_t * user_map
Attribute map applied to users and profiles.
Definition rlm_ldap.h:156
rlm_rcode_t rcode
What rcode we'll finally respond with.
Definition rlm_ldap.h:215
static char const * rlm_find_user_dn_cached(rlm_ldap_t const *inst, request_t *request)
Definition rlm_ldap.h:257
trunk_conf_t trunk_conf
Trunk configuration.
Definition rlm_ldap.h:133
module_instance_t const * mi
Module instance data for thread lookups.
Definition rlm_ldap.h:136
void rlm_ldap_check_reply(request_t *request, rlm_ldap_t const *inst, char const *inst_name, bool expect_password, fr_ldap_thread_trunk_t const *ttrunk)
Verify we got a password from the search.
Definition user.c:264
fr_value_box_t const * expect_password
True if the user_map included a mapping between an LDAP attribute and one of our password reference a...
Definition rlm_ldap.h:158
unlang_action_t rlm_ldap_check_cached(unlang_result_t *p_result, rlm_ldap_t const *inst, request_t *request, fr_value_box_t const *check)
Check group membership attributes to see if a user is a member.
Definition groups.c:1181
fr_pair_list_t * trigger_args
Pairs passed to trigger request for standard trunk.
Definition rlm_ldap.h:138
fr_value_box_t user_filter
Filter to use when searching for users.
Definition rlm_ldap.h:167
fr_value_box_t default_profile
If this is set, we will search for a profile object with this name, and map any attributes it contain...
Definition rlm_ldap.h:150
ldap_group_xlat_status_t
State list for xlat evaluation of LDAP group membership.
Definition rlm_ldap.h:220
@ GROUP_XLAT_MEMB_FILTER
Definition rlm_ldap.h:222
@ GROUP_XLAT_MEMB_ATTR
Definition rlm_ldap.h:223
@ GROUP_XLAT_FIND_USER
Definition rlm_ldap.h:221
HIDDEN fr_dict_attr_t const * attr_cleartext_password
Definition rlm_ldap.c:328
module_instance_t const * dlinst
Definition rlm_ldap.h:202
ldap_access_state_t rlm_ldap_check_access(rlm_ldap_t const *inst, request_t *request, LDAPMessage *entry)
Check for presence of access attribute in result.
Definition user.c:212
char const * dn
Definition rlm_ldap.h:234
Call environment used in LDAP authorization.
Definition rlm_ldap.h:145
Holds state of in progress async authorization.
Definition rlm_ldap.h:201
Holds state of in progress group membership check xlat.
Definition rlm_ldap.h:229
Call environment used in group membership xlat.
Definition rlm_ldap.h:165
Module instance data.
Definition module.h:285
eap_aka_sim_process_conf_t * inst
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
Common configuration parameters for a trunk.
Definition trunk.h:224
static TALLOC_CTX * xlat_ctx