import from HEAD:
[freeradius.git] / doc / rlm_ldap
1 1.   INSTALLATION
2
3 This module depends on OpenLDAP v2.x SDK libraries.  For details on obtaining
4 source of OpenLDAP look at <http://www.openldap.org>.  OpenLDAP SDK in turn
5 depends on OpenSSL crypto libraries and (optionaly) on Cyrus-SASL libraries.
6
7 See also: http://www.tldp.org/HOWTO/LDAP-Implementation-HOWTO/radius.html
8
9 It's not up to date, though.  For example, you do NOT have to edit
10 the "dictionary" file.
11
12
13 2. LDAP ATTRIBUTES
14
15 The mapping between radius and ldap attributes is in raddb/ldap.attrmap. You
16 should edit the file and add any new mapping which you need. The schema files
17 is located in doc/RADIUS-LDAPv3.schema. Before adding any radius attributes
18 the ldap server schema should be updated.  All ldap entries containing radius
19 attributes should contain at least "objectclass: radiusprofile"
20
21 radiusCheckItem and radiusReplyItem are special. They allow the administrator
22 to add any check or reply item respectively without adding it in the ldap
23 schema. The format should be <ldap-attribute>: <radius-attribute> <operator>
24 <value>
25
26 ie radiusReplyItem: Cisco-AVPair := "ip:addr-pool=dialin_pool"
27
28 3. CONFIGURATION
29
30 See the "modules" section of "radiusd.conf", and look for the "ldap"
31 section.  It lists and documents the common configuration items.
32
33 Note that LDAP is a database, NOT an authentication server.
34 FreeRADIUS is an authentication server, NOT a database.  What this
35 means is that LDAP "bind as user" is almost always a bad idea.  Using
36 "Auth-Type = LDAP" is almost always a bad idea.  We STRONGLY recommend
37 that you do NOT list "ldap" in the "authenticate" section of
38 radiusd.conf.  Doing so can cause all sorts of problems for people who
39 are unfamiliar with RADIUS and LDAP.
40
41 The normal configuration is to configure the "ldap" section in
42 radiusd.conf, and list "ldap" in the "authorize" section.  FreeRADIUS
43 should then be able to use LDAP to find the "known good" password for
44 the user.  FreeRADIUS will then use this password to perform PAP,
45 CHAP, MS-CHAP, or any other kind of authentication that the user has
46 requested.
47
48 If you use "Auth-Type := LDAP", then the ONLY authentication protocol
49 that will work is PAP.  EAP will not work (i.e. all wireless
50 authentication).  CHAP will not work, and MS-CHAP will not work.
51
52
53 4. USAGE
54
55 MODULE MESSAGES: On user rejection rlm_ldap will return the following module
56 messages:
57
58 "rlm_ldap: User not found" "rlm_ldap: Access Attribute denies access"
59 "rlm_ldap: Bind as user failed"
60
61 These messages will be visible in radius.log as aditional information in
62 "Login incorrect" and "Invalid user" log messages.
63
64 LDAP XLAT: The ldap module now supports LDAP URLs in xlat strings. That is you
65 can now add LDAP URLs in the configuration options and hopefully shortly also
66 in the users file. The strings will be of the following form:
67
68 %{ldap:ldap:///dc=company,dc=com?uid?sub?uid=%u}
69
70 The requested attributes list MUST contain only ONE attribute. In case this
71 attribute is multi valued which value is returned is considered UNDEFINED.
72 Also, adding the host:port information SHOULD be avoided unless there are more
73 than one ldap module instances in which case the host,port information can be
74 used to distinguish which module will actually return the information (the
75 xlat function will return NULL if the host,port information does not
76 correspond to the configured attributes).  If there are more than one
77 instances the module instance name can be used instead of the string 'ldap'
78 before the ldap url to decide which instance will return the information.
79 That is the xlat string will be of the form:
80
81 %{$instance_name:ldap:///dc=comapny,dc=com?uid?sub?uid=%u}
82
83 i.e.: ${ldap_company1:ldap:///dc=company1,dc=com?uid?sub?uid=%u}
84
85
86 USER PROFILE ATTRIBUTE: The module can use the User-Profile attribute. If it
87 is set, it will assume that it contains the DN of a profile entry containing
88 radius attributes. This entry will _replace_ the default profile directive.
89 That way we can use different profiles based on checks on the radius
90 attributes contained in the Access-Request packets. For example (users file):
91
92 DEFAULT Service-Type == Outbound-User, User-Profile := "uid=outbound-dialup,dc=company,dc=com"
93  
94
95 GROUP SUPPORT: The module supports searching for ldap groups by use of the
96 Ldap-Group attribute. As long as the module has been instanciated it can be
97 used to do group membership checks through other modules. For example in the
98 users file:
99
100 DEFAULT Ldap-Group == "disabled", Auth-Type := Reject 
101         Reply-Message = "Sorry, you are not allowed to have dialup access"
102
103 DNs are also accepted as Ldap-Group values, i.e.:
104
105 DEFAULT Ldap-Group == "cn=disabled,dc=company,dc=com", Auth-Type := Reject
106         Reply-Message = "Sorry, you are not allowed to have dialup access"
107
108
109
110 Also if you are using multiple ldap module instances a per instance
111 Ldap-Group attribute is registered and can be used. It is of the form
112 <instance_name>-Ldap-Group. In other words if in radiusd.conf we
113 configure an ldap module instance like:
114
115 ldap myname { [...] }
116
117 we can then use the myname-Ldap-Group attribute to match user
118 groups. Make sure though that the ldap module is instantiated *before*
119 the files module so that it will have time to register the
120 corresponding attribute. One solution would be to add the ldap module
121 in the instantiate{} block in radiusd.conf
122
123
124 USERDN Attribute:
125 When rlm_ldap has found the DN corresponding to the username provided
126 in the access-request (all this happens in the authorize section) it
127 will add an Ldap-UserDN attribute in the request items list containing
128 that DN. The attribute will be searched for in the authenticate
129 section and if present will be used for authentication (ldap bind with
130 the user DN/password). Otherwise a search will be performed to find
131 the user dn. If the administrator wishes to use rlm_ldap only for
132 authentication or does not wish to populate the identity,password
133 configuration attributes he can set this attribute by other means and
134 avoid the ldap search completely. For instance it can be set through
135 the hints file in the authorize section:
136
137 DEFAULT Ldap-UserDN := `uid=%{User-Name},ou=people,dc=company,dc=com`
138
139 The "users" file won't work, because it can't add items to the request.
140
141
142 DIRECTORY COMPATIBILITY NOTE: If you use LDAP only for authorization and
143 authentication (e.g. you can not afford schema extension), we suggest you set
144 all necessary attributes in raddb/users file with following authorize section
145 of radiusd.conf :
146
147 authorize { ldap { notfound = return } files  }
148
149
150 5. LDAP and Active Directory
151
152 Active directory does not return anything in the userPassword
153 attribute, unlike other LDAP servers.  As a result, you cannot use
154 Active Directory as an LDAP server to perform CHAP, MS-CHAP, or
155 EAP-MD5 authentication.  You can only use PAP, and then only if you
156 list "ldap" in the "authenticate" section.  As noted above, we do not
157 recommend this unless you have no other choice.
158
159 To do MS-CHAP against an Active Directory domain, see the comments in
160 radiusd.conf, in the "mschap" section, about "ntlm_auth".  You will
161 need to install Samba.  The MS-CHAP module will then run ntlm_auth
162 when it receives an MS-CHAP request.  The ntlm_auth program will
163 communicate with winbindd, which will then talk to Active Directory.
164
165 This will only work for one Active Directory domain.  If you need to
166 authenticate against two or more domains, the solution becomes
167 extremely difficult.
168
169
170 If you see "Operations error" returned from an LDAP query, you may
171 need to set dsHeuristics to 0000002 in Active Directory.  This allows
172 searches to function similar to how they did in Active Directory
173 2k2. You can update dsHeuristics by launching ldp.exe, going to
174 'connection' and create a new connection. Then goto bind and bind to
175 your ldap server. Next select the 'Browse' menu and choose
176 'modify'. The DN *might* look like this:
177
178 CN=Directory Service,CN=Windows
179 NT,CN=Services,CN=Configuration,DC=mycompany,DC=com
180
181 Attribute is: dsHeuristics
182 Value is: 0000002
183
184 Set the operation to replace and you should be set.  This should solve
185 the 'Operations error' error that happens when attempting to search
186 without specifying an OU.
187
188
189
190 6. Detailed documentation for the module configuration
191
192   modules { ...
193         
194         ldap {
195
196 #       server: LDAP server hostname/ip address
197 #
198 #       Optionaly could contain space separated list of host[:port], but
199 #       redundancy/resiliency is better acheived configuring multiple rlm_ldap
200 #       module instances and invocing them in   redundand/failover
201 #       configuration in authorize/authenticate sections
202 #
203 #       You can also pass an ldap url like ldap://localhost
204 #       That way you can also specify alternative ldap schemas like
205 #       ldaps:// or ldapi://
206 #       The port directive will be ignored in that case
207 #               
208 #       default: settings for your system, as set in etc/openldap/ldap.conf
209 #
210                 server   = localhost
211
212 #       port: LDAP server port
213 #               
214 #       If LDAP server port is set to 636 (ldaps), SSL connection is enforced.
215 #       This feature is useful for LDAP servers which support SSL, but don't
216 #       do TLS negotiation (like Novell eDirectory).
217 #       
218 #       default: 389 (ldap)
219 #
220                 port = 636
221
222 #       net_timeout: # of seconds to wait for response of the server (network
223 #       failures) default: 10
224 #
225                 net_timeout = 1
226
227 #       timeout: # seconds to wait for LDAP query to finish default: 20
228 #
229                 timeout = 2
230
231 #       timelimit: # of seconds server has to process the query (server-side
232 #       time limit) default: 20
233 #
234                 timelimit = 5
235
236 #       ldap_debug: debug flag for LDAP SDK (see OpenLDAP documentation)
237 #       default: 0x0000 (no debugging messages)
238 #       Example:(LDAP_DEBUG_FILTER+LDAP_DEBUG_CONNS)
239                 ldap_debug = 0x0028 
240
241 #       identity: DN under which LDAP searches are done password: pasword
242 #       which authenticate this DN default: anonymous bind, no password
243 #       required NOTE: searches are done now over unencrypted connection!
244 #
245 #       identity = "cn=admin,o=My Org,c=UA" password = mypass
246
247
248 #       ldap_connections_number: The number of ldap connections that the
249 #       module will keep open to use in requests. Usually it will not need to
250 #       be larger than 5-10 connections default: 5
251
252         ldap_connections_number = 5
253
254 #       basedn = <Base of LDAP searches>
255 #
256                 basedn   = "o=My Org,c=UA"
257
258 #       filter: LDAP search filter, to locate user object using name supplied
259 #       by client during Radius authentication
260 #       
261 #       default: filter   = "(uid=%u)"
262
263 #       base_filter: The LDAP search filter used for base scope searches, like
264 #       when searching for the default or regular profiles
265 #
266 #       deafault: base_filter = "(objectclass=radiusprofile)"
267
268                 filter   = "(uid=%u)"
269
270 #       start_tls: When set to "yes" the StartTLS extended operation is used to
271 #       start TLS transport encryption.
272                 start_tls = no
273
274 #       tls_mode: When set to "yes" OR the server port is 636 we try to connect with TLS
275 #       Start TLS should be prefered, tls_mode is provided only for ldap servers
276 #       like Active Directory which do not support it.
277 #       default: no
278
279                 tls_mode = no
280
281 #       tls_cacertfile: A PEM-encoded file that contains the CA Certificates that
282 #       you trust
283                 tls_cacertfile = /path/to/cacert.pem
284
285 #       tls_cacertdir: Path the a directory of CA Certificates that you trust, the
286 #       directory must be in "hash format" (see openssl verify)
287                 tls_cacertdir = /path/to/ca/dir/
288
289 #       tls_certfile: The PEM Encoded certificate file that we should present to
290 #       clients connecting
291                 tls_certfile = /path/to/radius.crt
292
293 #       tls_keyfile: The PEM Encoded private key that we should use to encrypt the
294 #       session
295                 tls_keyfile = /path/to/radius.key
296
297 #       tls_randfile: A file containing random data to seed the OpenSSL PRNG.  Not
298 #       needed if your OpenSSL is already properly random.
299                 tls_randfile = /path/to/rnd
300
301 #       tls_require_cert: Certificate Verification requirements.  Can be "never"
302 #       (don't even bother trying), "allow" (try, but don't fail if the cerificate
303 #       can't be verified), or "demand" (fail if the certificate doesn't verify.)
304 #       The default is "allow"
305                 tls_require_cert = "allow"
306
307 #       default_profile: DN of a LDAP object, which contains default RADIUS
308 #       attributes.  default: NULL - use only user specific attributes or
309 #       attributes, supplied by other modules.
310 #               
311         default_profile = "cn=RadProfile,o=My Org,c=UA"
312
313 #       profile_attribute: user object attribute, which contains DN of
314 #       radiusProfile object for this user.  default: NULL - use only user
315 #       specific attributes or attributes, supplied by other modules.
316 #
317 #       profile_attribute = "radiusProfileDn"
318
319 #       access_attr_used_for_allow: Define if the access attribute (described
320 #       below) will be used to allow access (meaning if it exists then user
321 #       remote access will be allowed) or to deny access.  default: yes - used
322 #       to allow access
323
324 #       access_attr: if attribute is specified, module checks for its
325 #       existance in user object.  If access_attr_used_for_allow is set to
326 #       yes: If it exists the user is allowed to get remote access.  If it
327 #       exists and is set to FALSE the user is denied remote access.  If it
328 #       does not exist user is denied remote access by default if
329 #       access_attr_used_for_allow is set to no: If it exists the user is
330 #       denied remote access.  If it does not exist user is allowed remote
331 #       access.
332 #
333 #       default: NULL - don't check for the attribute
334
335         access_attr = "dialupAccess"
336
337 #       password_header: If the user password is available we add it to the
338 #       check items (to assist in CHAP ie) striping any headers first.
339 #       NOTE: The password_header directive is NOT case insensitive
340 #       default: NULL
341 #
342 #       password_header = "{clear}"
343
344 #       password_attribute: Define the attribute which contains the user
345 #       password.
346 #       While integrating FreeRADIUS with Novell eDirectory, set
347 #       'password_attribute = nspmpassword' in order to use the universal
348 #       password of the eDirectory users for RADIUS authentication. This will
349 #       work only if FreeRADIUS is configured to build with --with-edir option.
350 #
351 #       default: NULL - don't add password
352 #
353 #       password_attribute = "userPassword"
354
355 #       password_radius_attribute: Defined the RADIUS attribute where the extracted
356 #       user password will be stored to. Can be used to set it to NT-Password or any
357 #       other similar attribute instead of the default
358 #
359 #       default: User-Password
360 #
361 #       password_radius_attribute = "NT-Password"
362
363 #       edir_account_policy_check: Specifies if the module has to enforce
364 #       Novell eDirectory account policy check and intruder detection for
365 #       RADIUS users.  This will work only if FreeRADIUS is configured to build
366 #       with --with-edir option.
367 #
368 #       default: yes - eDirectory account policy check enabled
369 #
370 #       edir_account_policy_check = no
371
372 #       groupname_attribute: The attribute containing group name in the LDAP
373 #       server. It is used to search group by name.
374 #
375 #       default: cn - Search filter is "(cn=%GroupName)"
376 #
377 #       groupname_attribute = "cn"
378
379 #       compare_check_items: Specifies if the module will do a comparison on
380 #       the check items extracted from the ldap with the corresponding items
381 #       present in the incoming request.
382 #
383 #       default: no - don't do any comparisons
384 #
385 #       compare_check_items = yes
386
387 #       do_xlat: Specifies if the module will do an xlat on the radius attributes
388 #       extracted from the ldap database. Also the attribute operators will be
389 #       honored. If the directive is set to 'no' then we will fall back to the
390 #       pairadd() function which will just add the attributes at the end of the
391 #       corresponding attribute list (check or reply items). This can be used to
392 #       fall back to 0.8.1 behaviour without changing the ldap data or to gain a
393 #       little performance if the ldap data is rather simple (no special operators)
394 #
395 #       default: yes - do an xlat and honor operators
396 #
397 #       do_xlat = yes
398         
399
400 #       groupmembership_filter: The filter to search for group membership of a
401 #       particular user after we have found the DN for the group.
402 #
403 #       default: (|(&(objectClass=GroupOfNames)(member=%{Ldap-UserDn}))(&(objectClass=GroupOfUniqueNames)(uniquemember=%{Ldap-UserDn})))
404 #
405 #       groupmembership_filter = "(|(&(objectClass=GroupOfNames)(member=%{Ldap-UserDn}))(&(objectClass=GroupOfUniqueNames)(uniquemember=%{Ldap-UserDn})))"      
406
407
408 #       groupmembership_attribute: The attribute in the user entry that states
409 #       the group the user belongs to.  The attribute can either contain the
410 #       group name or the group DN. If it contains the group DN
411 #       groupmembership_attribute will also be used to find the group's name.
412 #       The attribute will be used after a search based on the
413 #       groupname_attribute and groupmembership_filter has failed.  default:
414 #       NULL - don't search for a group based on attributes in the user entry.
415 #
416 #       groupmembership_attribute = "radiusGroupName"
417
418         } }
419
420 NOTE: As LDAP is case insensitive, you should probably also set "lower_user =
421 yes" and "lower_time = before" in main section of radiusd.conf, to get limits
422 on simultaneous logins working correctly. Otherwise, users will be able get
423 large number of sessions, capitalizing parts of their login names.
424