ldap-guide.html 16.5 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
4
    <title>Wildfire LDAP Guide</title>
5
    <link href="style.css" rel="stylesheet" type="text/css">
Matt Tucker's avatar
Matt Tucker committed
6
</head>
7

Matt Tucker's avatar
Matt Tucker committed
8 9 10
<body>
<a name="top"></a>

11
<h1>Wildfire LDAP Guide</h1>
Matt Tucker's avatar
Matt Tucker committed
12 13 14 15

<h2>Introduction</h2>

<p>
16
    This document details how to configure your Wildfire installation to use
17
    an external LDAP store when authenticating users and loading user profile information.
Matt Tucker's avatar
Matt Tucker committed
18
</p>
19

Matt Tucker's avatar
Matt Tucker committed
20
<h2>Background</h2>
21

Matt Tucker's avatar
Matt Tucker committed
22
<p>
23 24 25 26
    LDAP (Lightweight Directory Access Protocol) has emerged as a dominant standard
    for user authentication and for storage of user profile data. It serves as a
    powerful tool for large organizations (or those organizations integrating many
    applications) to simplify user management issues.
Matt Tucker's avatar
Matt Tucker committed
27
</p>
28

Matt Tucker's avatar
Matt Tucker committed
29
<p>
30
    By default, Wildfire stores all user data in a database and performs
31
    authentication using database lookups. The LDAP module replaces that
32
    functionality and allows Wildfire to:
33 34 35 36 37
    <ul>
        <li>Use a LDAP server to authenticate a user's identity.</li>
        <li>Load user profile information from a LDAP directory.</li>
        <li>Load group information from an LDAP directory.</li>
    </ul>
38

39
    <b>Note:</b> Wildfire treats the LDAP directory as read-only.
Matt Tucker's avatar
Matt Tucker committed
40
</p>
41

Matt Tucker's avatar
Matt Tucker committed
42
<p>
43
    This document will guide you through configuring LDAP support in Wildfire. These
44
    instructions assume that you're a competent LDAP user, and that you're familiar
45
    with Wildfire setup issues.
Matt Tucker's avatar
Matt Tucker committed
46 47 48
</p>

<h2>Configuration</h2>
49

Matt Tucker's avatar
Matt Tucker committed
50
<p>
51 52 53
    In order to configure your server to use LDAP:
    <ol>
        <li>
54
            Stop Wildfire.
55
        </li>
56
        <li>Edit <tt>conf/wildfire.xml</tt> in your Wildfire installation folder as
57 58 59
            described below.
        </li>
        <li>
60
            Restart Wildfire.
61 62
        </li>
    </ol>
Matt Tucker's avatar
Matt Tucker committed
63
</p>
64

Matt Tucker's avatar
Matt Tucker committed
65
<h3>Editing the Config File</h3>
66

Matt Tucker's avatar
Matt Tucker committed
67
<p>
68
    Open the configuration file <tt>conf/wildfire.xml</tt> from your Wildfire
69 70 71 72 73 74
    installation in your favorite
    editor and add or change the following settings. Properties flagged with (<font color="red">
    <b>*</b></font>)
    must be set. Properties flagged with (<font color="red"><b>**</b></font>) must be set in order
    to enable LDAP group
    support, all other properties are optional:
Matt Tucker's avatar
Matt Tucker committed
75 76
</p>
<ul>
77
    <li>provider.user.className <font color="red"><b>*</b></font> -- set the value to
78
        "org.jivesoftware.wildfire.ldap.LdapUserProvider".</li>
79
    <li>provider.auth.className <font color="red"><b>*</b></font> -- set the value to
80
        "org.jivesoftware.wildfire.ldap.LdapAuthProvider".</li>
81
    <li>provider.group.className <font color="red"><b>**</b></font> -- set the value to
82
        "org.jivesoftware.wildfire.ldap.LdapGroupProvider".</li>
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    <li>ldap.host <font color="red"><b>*</b></font> -- LDAP server host; e.g. localhost or
        machine.example.com, etc.</li>
    <li>ldap.port -- LDAP server port number. If this property is not set, the default value is
        389.</li>
    <li>ldap.baseDN <font color="red"><b>*</b></font> -- the starting DN that searches for users
        will performed with.
        The entire subtree under the base DN will be searched for user accounts.
    </li>
    <li>ldap.alternateBaseDN -- a second DN in the directory can optionally be set. If set, the
        alternate base DN
        will be used for authentication and loading single users, but will not be used to display a
        list of users
        (due to technical limitations).
        <li>ldap.adminDN -- a directory administrator's DN. All directory operations will be
            performed
            with this account. The admin must be able to perform searches and load user records. The
            user does
100
            not need to be able to make changes to the directory, as Wildfire treats the
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
            directory as read-only.
            If this property is not set, an anonymous login to the server will be attempted.
        </li>
        <li>ldap.adminPassword -- the password for the directory administrator.</li>
        <li>ldap.usernameField -- the field name that the username lookups will be performed on. If
            this property is not set,
            the default value is <tt>uid</tt></li>
        <li>ldap.nameField -- the field name that holds the user's name. If this property is not
            set, the default value is
            <tt>cn</tt></li>
        <li>ldap.emailField -- the field name that holds the user's email address. If this property
            is not set,
            the default value is <tt>mail</tt>.</li>
    <li>ldap.searchFilter -- the search filter that should be used when loading users. If this
        property
        is not set, the default search will be for users that have the attribute specified by
        ldap.usernameField.
        <li>ldap.debugEnabled -- a value of "true" if debugging should be turned on. When on, trace
            information about buffers sent and received by the LDAP provider is written to
            System.out</li>
        <li>ldap.sslEnabled -- a value of "true" to enable SSL connections to your LDAP server. If
            you
            enable SSL connections, the LDAP server port number most likely should be changed to
            636.</li>
    <li>ldap.initialContextFactory -- the name of the class that should be used as an initial
        context
        factory. if this value is not specified, "com.sun.jndi.ldap.LdapCtxFactory" will be used
        instead.
        Most users will not need to set this value.
    <li>ldap.autoFollowReferrals -- a value of "true" indicates that LDAP referrals should be
        automatically
        followed. If this property is not set or is set to "false", the referral policy used is left
        up to
        to the provider. A referral is an entity that is used to redirect a client's request to
        another server.
        A referral contains the names and locations of other objects. It is sent by the server to
        indicate
        that the information that the client has requested can be found at another location (or
        locations),
        possibly at another server or several servers.
    <li>ldap.connectionPoolEnabled -- a value of "false" disables LDAP connection pooling. If this
        property is not set, the default value is "true".
    <li>ldap.groupNameField -- the field name that the groupname lookups will be performed on. If
        this property is not set,
        the default value is <tt>cn</tt></li>
    <li>ldap.groupMemberField -- the field name that holds the members in a group. If this property
        is not set,
        the default value is <tt>member</tt></li>
    <li>ldap.groupDescriptionField -- the field name that holds the description a group. If this
        property is not set,
        the default value is <tt>description</tt></li>
    <li>ldap.posixMode -- a value of "true" means that users are stored within the group by their
        user name alone.
        A value of "false" means that users are stored by their entire DN within the group. If this
        property is not set,
        the default value is <tt>false</tt></li>
    <li>ldap.groupSearchFilter -- the search filter that should be used when loading groups. If this
        property is not set,
        the default value is <tt>("ldap.groupNameField"={0})</tt></li>
Matt Tucker's avatar
Matt Tucker committed
160
</ul>
161

Matt Tucker's avatar
Matt Tucker committed
162
<p>
163
    Below is a sample config file section:
Matt Tucker's avatar
Matt Tucker committed
164 165
</p>
<pre><code>
166 167 168
    &lt;jive&gt;
      ...
      &lt;ldap&gt;
Matt Tucker's avatar
Matt Tucker committed
169 170
        &lt;host&gt;&lt;/host&gt;
        &lt;port>389&lt;/port&gt;
171
        &lt;usernameField&gt;uid&lt;/usernameField&gt;
Matt Tucker's avatar
Matt Tucker committed
172 173
        &lt;nameField&gt;cn&lt;/nameField&gt;
        &lt;emailField&gt;mail&lt;/emailField&gt;
Matt Tucker's avatar
Matt Tucker committed
174 175
        &lt;baseDN&gt;ou=People;dc=example;dc=com&lt;/baseDN&gt;
        &lt;adminDN&gt;cn=Directory Administrator&lt;/adminDN&gt;
Matt Tucker's avatar
Matt Tucker committed
176
        &lt;adminPassword&gt;&lt;/adminPassword&gt;
177 178
      &lt;/ldap&gt;
      &lt;provider&gt;
Matt Tucker's avatar
Matt Tucker committed
179
        &lt;user&gt;
180
          &lt;className&gt;org.jivesoftware.wildfire.ldap.LdapUserProvider&lt;/className&gt;
Matt Tucker's avatar
Matt Tucker committed
181 182
        &lt;/user&gt;
        &lt;auth&gt;
183
          &lt;className&gt;org.jivesoftware.wildfire.ldap.LdapAuthProvider&lt;/className&gt;
Matt Tucker's avatar
Matt Tucker committed
184
        &lt;/auth&gt;
185
        &lt;group&gt;
186
          &lt;className&gt;org.jivesoftware.wildfire.ldap.LdapGroupProvider&lt;/className&gt;
187
        &lt;/group&gt;
188 189 190
      &lt;/provider&gt;
      ...
    &lt;/jive&gt;
Matt Tucker's avatar
Matt Tucker committed
191 192
</code></pre>

193
<p>You'll most likely want to change which usernames are authorized to login to the
194 195
    admin console. By default, only the user with username "admin" is allowed to login. However,
    you may have different users in your LDAP directory that you'd like to be administrators. The
196
    list of authorized usernames is controlled via the <tt>admin.authorizedUsernames</tt>
197
    property. For example, to let the usersnames "joe" and "jane" login to the admin console:</p>
Matt Tucker's avatar
Matt Tucker committed
198 199

<pre><code>
200 201
    &lt;jive&gt;
      ...
202
      &lt;admin&gt;
203
        ...
Matt Tucker's avatar
Matt Tucker committed
204
        &lt;authorizedUsernames&gt;joe, jane&lt;/authorizedUsernames&gt;
205
      &lt;/admin&gt;
206 207
      ...
    &lt;/jive&gt;
Matt Tucker's avatar
Matt Tucker committed
208
</code></pre>
209

Matt Tucker's avatar
Matt Tucker committed
210
<p><a name=""><h2>Custom Search Filter</h2></a></p>
211

212
<p>By default, Wildfire will load all objects under the baseDN that
213 214 215 216 217 218 219 220 221
    have the attribute specified by <tt>ldap.usernameField</tt>. In the
    case that the username field is set to "uid", the search for all users
    would be "(uid=*)". However, there are cases when this logic does
    not work -- for example, when a directory contains other objects besides
    users but all objects share "uid" as a unique identifier field. In that
    case, you may need to specify a custom search filter using
    <tt>ldap.searchFilter</tt>. As an example, a search filter for all users
    with a "uid" and a "cn" value of "joe" would
    be:</p>
222 223 224 225

<pre>(&(uid={0})(cn=joe))</pre>

<p>The "{0}" value in the filter above is a token that should be present in
226 227
    all custom search filters. It will be dynamically replaced with "*" when
    loading the list of all users or a username when loading a single user.</p>
228 229

<p>Some custom search filters may include reserved XML entities such as
230
    "&". In that case, you must enter the search filter into the wildfire.xml
231
    file using CDATA:
232

233
    <pre>&lt;searchFilter&gt;&lt;![CDATA[(&(sAMAccountName={0})(|(givenName=GEORGE)(givenName=admin)))]]&gt;&lt;/searchFilter&gt;</pre>
234

235
    <p><a name="ctxFactory"><h2>Custom Inital Context Factory</h2></a></p>
236

237 238 239
    <p>
        Some LDAP servers or application servers may require that a different LDAP
        initial context factory be used rather than the default (com.sun.jndi.ldap.LdapCtxFactory).
240
        You can set a custom initial context factory by adding the following to wildfire.xml:
241 242 243 244

<pre>
  &lt;ldap&gt;
    ... other ldap settings here
245
    &lt;initialContextFactory&gt;com.foo.factoryClass&lt;/initialContextFactory&gt;
246 247
  &lt;/ldap&gt;</pre>
    </p>
248

249
    <p><a name="connectionPool"><h2>Connection Pooling</h2></a></p>
250

251 252 253 254 255
    The default LDAP provider (Sun's) support pooling of connections to the LDAP
    server. Connection pooling can greatly improve performance, especially on
    systems with high load. Connection pooling is enabled by default, but can
    be disabled by setting the Jive property <tt>ldap.connectionPoolEnabled</tt>
    to <tt>false</tt>:
256

257 258 259 260
    <pre>&lt;ldap&gt;
        ... other ldap settings here
        &lt;connectionPoolEnabled&gt;false&lt;/connectionPoolEnabled&gt;
        &lt;/ldap&gt;</pre></p>
261 262

<p>
263 264 265
    You should set several Java system properties to change default pool settings.
    For more information, see the following pages:
    <ul>
266

267 268 269 270
        <li><a href="http://java.sun.com/products/jndi/tutorial/ldap/connect/pool.html">
            http://java.sun.com/products/jndi/tutorial/ldap/connect/pool.html</a>
        <li><a href="http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html">
            http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html</a>
271

272
    </ul>
273
</p>
274

275
<p>Note that if you turn on LDAP debugging, connection pooling will not be enabled.
276 277 278 279 280 281 282 283 284 285 286 287
    If SSL LDAP mode is enabled, you must set a system property to enable pooling of
    SSL LDAP connections.</p>

<p><a name="vcard"><h2>LDAP vCard Integration</h2></a></p>

<p>The LDAP vCard provider will expose LDAP profile information as vCard data for XMPP
clients that support the XMPP vCard extension. First, enable the provider:</p>

<pre>
    &lt;provider&gt;
      ...
      &lt;vcard&gt;
288
        &lt;className&gt;org.jivesoftware.wildfire.ldap.LdapVCardProvider&lt;/className&gt;
289 290 291 292 293
      &lt;/vcard&gt;
      ...
    &lt;/provider&gt;
</pre>

294
<p>Next, you must add mappings between LDAP fields and vCard fields in the wildfire.xml file.
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
    The vcard attributes are configured by adding an attrs="attr1,attr2" attribute to the vcard
    elements. Arbitrary text can be used for the element values as well as MessageFormat style
    placeholders for the ldap attributes. For example, if you wanted to map the LDAP attribute
    displayName to the vcard element FN, the XML snippet would be:
    &lt;FN attrs="displayName"&gt;{0}&lt;/FN&gt;</p>

<p>The vCard XML must be escaped in CDATA and must also be well formed. It is the exact
    XML this provider will send to a client after after stripping attr attributes and populating
    the placeholders with the data retrieved from LDAP. This system should be flexible enough to
    handle any client's vCard format. An example mapping follows.</p>

<pre>
    &lt;ldap&gt;
      &lt;vcard-mapping&gt;
        &lt;![CDATA[
          &lt;vCard xmlns='vcard-temp'&gt;
            &lt;FN attrs=&quot;displayName&quot;&gt;{0}&lt;/FN&gt;
            &lt;NICKNAME attrs=&quot;uid&quot;&gt;{0}&lt;/NICKNAME&gt;
            &lt;BDAY attrs=&quot;dob&quot;&gt;{0}&lt;/BDAY&gt;
            &lt;ADR&gt;
              &lt;HOME/&gt;
              &lt;EXTADR&gt;Ste 500&lt;/EXTADR&gt;
              &lt;STREET&gt;317 SW Alder St&lt;/STREET&gt;
              &lt;LOCALITY&gt;Portland&lt;/LOCALITY&gt;
              &lt;REGION&gt;Oregon&lt;/REGION&gt;
              &lt;PCODE&gt;97204&lt;/PCODE&gt;
              &lt;CTRY&gt;USA&lt;/CTRY&gt;
            &lt;/ADR&gt;
            &lt;TEL&gt;
              &lt;HOME/&gt;
              &lt;VOICE/&gt;
              &lt;NUMBER attrs=&quot;telephoneNumber&quot;&gt;{0}&lt;/NUMBER&gt;
            &lt;/TEL&gt;
            &lt;EMAIL&gt;
            &lt;INTERNET/&gt;
            &lt;USERID attrs=&quot;mail&quot;&gt;{0}&lt;/USERID&gt;
            &lt;/EMAIL&gt;
            &lt;TITLE attrs=&quot;title&quot;&gt;{0}&lt;/TITLE&gt;
            &lt;ROLE attrs=&quot;&quot;&gt;{0}&lt;/ROLE&gt;
            &lt;ORG&gt;
              &lt;ORGNAME attrs=&quot;o&quot;&gt;{0}&lt;/ORGNAME&gt;
              &lt;ORGUNIT attrs=&quot;&quot;&gt;{0}&lt;/ORGUNIT&gt;
            &lt;/ORG&gt;
            &lt;URL attrs=&quot;labeledURI&quot;&gt;{0}&lt;/URL&gt;
            &lt;DESC attrs=&quot;uidNumber,homeDirectory,loginShell&quot;&gt;
            uid: {0} home: {1} shell: {2}
            &lt;/DESC&gt;
          &lt;/vCard&gt;
        ]]&gt;
      &lt;/vcard-mapping&gt;
    &lt;/ldap&gt;
</pre>
347 348

<h2>LDAP FAQ</h2>
349

350 351
<p>

352 353
    <b>Can I create new users through Wildfire when using LDAP?</b>
    <ul>No, Wildfire treats LDAP directories as read-only. Therefore, it's
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
        not possible to create or edit users through the application.</ul>

    <b>Why is the list of usernames not sorted in the admin console when using LDAP?</b>
    <ul>Several popular LDAP servers such as OpenLDAP do not support server-side
        sorting of search results. On those servers, users will appear out of order.
        However, you can enable client-side sorting of search results by setting
        <tt>ldap.clientSideSorting</tt> to true in the XML configuration file.</ul>

    <b>I switched to LDAP and now cannot login to the admin console. What happened?</b>
    <ul>If you can no longer login to the admin console after switching, one of two
        things most likely happened:<ol>
        <li>By default, only the username "admin" is allowed to login to the
            admin console. Your directory may not contain a user with a username
            of "admin". In that case, you should modify the list of usernames authorized
            to login to the admin console (see above).
        <li>You may have set the baseDN to an incorrect value. The LDAP module
            recursively searches for users under the node in the directory specified
            by the baseDN. When the baseDN is incorrect, no users will be found.
    </ol>
        You can also enable debugging to get more information from the LDAP module. To
        do this, add &lt;log&gt;&lt;debug&gt;&lt;enabled&gt;true&lt;/enabled&gt;&lt;/debug&gt;&lt;/log&gt;
375
        to your <tt>conf/wildfire.xml</tt> file. Log statements will be written
376 377
        to the <tt>logs/debug.log</tt> file.
    </ul>
378 379


Matt Tucker's avatar
Matt Tucker committed
380
</body>
Matt Tucker's avatar
Matt Tucker committed
381
</html>