# Jive Messenger LDAP Guide

## Introduction

This document details how to configure your Jive Messenger installation to use an external LDAP store when authenticating users and loading user profile information.

## Background

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.

By default, Jive Messenger stores all user data in a database and performs authentication using database lookups. The LDAP module replaces that functionality and allows Jive Messenger to:

- Use a LDAP server to authenticate a user's identity.
- Load user profile information from a LDAP directory.

Note: Jive Messenger treats the LDAP directory as read-only.

This document will guide you through configuring LDAP support in Jive Messenger. These instructions assume that you're a competent LDAP user, and that you're familiar with Jive Messenger setup issues.

## Configuration

In order to configure your server to use LDAP:

1. Stop Jive Messenger.
2. Edit `conf/jive-messenger.xml` in your Jive Messenger installation folder as described below.
3. Restart Jive Messenger.

### Editing the Config File

Open the configuration file `conf/jive-messenger.xml` from your Jive Messenger installation in your favorite editor and add or change the following settings. Properties flagged with (*) must be set, all other properties are optional:

- * provider.user.className -- set the value to "org.jivesoftware.messenger.ldap.LdapUserProvider".
- * provider.auth.className -- set the value to "org.jivesoftware.messenger.ldap.LdapAuthProvider".
- * ldap.host -- LDAP server host; e.g. localhost or machine.example.com, etc.
- ldap.port -- LDAP server port number. If this property is not set, the default value is 389.
- * ldap.baseDN -- the starting DN that searches for users will performed with. The entire subtree under the base DN will be searched for user accounts.
- 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).
- 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 not need to be able to make changes to the directory, as Jive Messenger treats the directory as read-only. If this property is not set, an anonymous login to the server will be attempted.
- ldap.adminPassword -- the password for the directory administrator.
- ldap.usernameField -- the field name that the username lookups will be performed on. If this property is not set, the default value is `uid`
- ldap.nameField -- the field name that holds the user's name. If this property is not set, the default value is `cn`
- ldap.emailField -- the field name that holds the user's email address. If this property is not set, the default value is `mail`.
- 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
- 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.
- 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.
- 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.
- ldap.connectionPoolEnabled -- a value of "false" disables LDAP connection pooling. If this property is not set, the default value is "true".

Below is a sample config file section:

    <jive>
    ...
        <ldap>
            <host></host>
            <port>389</port>
            <usernameField>uid</usernameField>
            <nameField>cn</nameField>
            <emailField>mail</emailField>
            <baseDN>ou=People;dc=example;dc=com</baseDN>
            <adminDN>cn=Directory Administrator</adminDN>
            <adminPassword></adminPassword>
        </ldap>
        <provider>
            <user>
                <className>org.jivesoftware.messenger.ldap.LdapUserProvider</className>
            </user>
            <auth>
                <className>org.jivesoftware.messenger.ldap.LdapAuthProvider</className>
            </auth>
        </provider>
    ...
    </jive>

You'll most likely want to change which usernames are authorized to login to the 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 list of authorized usernames is controlled via the `adminConsole.authorizedUsernames` property. For example, to let the usersnames "joe" and "jane" login to the admin console:

    <jive>
    ...
        <adminConsole>
        ...
            <authorizedUsernames>joe, jane</authorizedUsernames>
        </adminConsole>
    ...
    </jive>

## Custom Inital Context Factory

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). You can set a custom initial context factory by adding the following to jive_config.xml:

    <ldap>
        ... other ldap settings here
        <initialContextFactory>com.foo.factoryClass</initialContextFactory>
    </ldap>

## Connection Pooling

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 `ldap.connectionPoolEnabled` to `false`:

    <ldap>
        ... other ldap settings here
        <connectionPoolEnabled>false</connectionPoolEnabled>
    </ldap>

You should set several Java system properties to change default pool settings. For more information, see the following pages:

- http://java.sun.com/products/jndi/tutorial/ldap/connect/pool.html
- http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html

Note that if you turn on LDAP debugging, connection pooling will not be enabled. If SSL LDAP mode is enabled, you must set a system property to enable pooling of SSL LDAP connections.

## LDAP FAQ

Can I create new users through Jive Messenger when using LDAP?

No, Jive Messenger treats LDAP directories as read-only. Therefore, it's not possible to create or edit users through the application.

Why is the list of usernames not sorted in the admin console when using LDAP?

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.

I switched to LDAP and now cannot login to the admin console. What happened?

If you can no longer login to the admin console after switching, one of two things most likely happened:

1. 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).
2. 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.

You can also enable debugging to get more information from the LDAP module. To do this, add <log><debug><enabled>true</enabled></debug></log> to your `conf/jive_messenger.xml` file. Log statements will be written to the `logs/debug.log` file.