How to Configure an External LDAP User Store / Active Directory User Store
All WSO2 Carbon based products can read and write users and roles from external LDAP user stores. You can configure Carbon products to access LDAP in one of the following modes.
All WSO2 Carbon based products can read users and roles from external LDAP/Active Directory user stores. You can configure Carbon products to read users/roles from your company LDAP. The "Read Only" mode does not write any data into the LDAP.
Note that LDAP is used going forward to refer to both LDAP and ActiveDirectory servers.
Step 1 : Backup <carbon-home>/repository/conf/user-mgt.xml.
- A sample file for LDAP user store is given below:
- A sample file for Active Directory is given below:
Copy the user-mgt-ldap.xml file and save it as
<PRODUCT_HOME>/repository/conf/user-mgt.xml. When you are configuring for ActiveDirectory, do the same to user-mgt-actdir.xml.
Note the following in your file.
Step 2 : Find a valid user that resides in the Directory Server. For example, let's say a valid user name is "AdminSOA". Update the Admin user section of your ldap configuration as follows. You don't have to update the password element; leave it as it is.
Step 3 : Update the connection details to suit your Directory Server.
Step 4 : Obtain a user who has permission to read all users/attributes and perform searches on the Directory Server from your LDAP administrator. For example, let's say the privileged user is "AdminLDAP" and password is "2010#Avrudu". Now update the following sections of the realm configuration.
Update the <Property name="UserSearchBase"> by giving the directory where the users are stored. LDAP searches for users will start from this location.
Step 5 : Set the attribute that you wish to be used as the username. The most common case is to use either "cn" or "uid" as the username. If you are not sure what attribute is available in your LDAP, check with your LDAP administrator.
For Active Directory this is different.
Step 6 : This is the most basic configuration. For more advanced options like "external roles", jump to step 7. Otherwise you are done! Now start your server and try to login as "AdminSOA". The password is the AdminSOA's password in the LDAP server.
If you are unable to login, contact the WSO2 carbon user group according to the contact details given under " section on the welcome page.
Step 7 : The realm can read roles from the Directory Server. It can read user/role mapping based on a backlink attribute or membership (user list) attribute.
- Step 7.1 : Reading roles based on a membership attribute. This is used by the ApacheDirectory server and OpenLDAP.
- Step 7.2 : Reading roles based on a backlink attribute. This is used by the Active Directory.
The following table contains detail descriptions of each property.
The connection URL to the database.
The user name used to connect to the database.
Password of the connection username.
Search base of users.
The LDAP query that should be used to search users.
Users can be authenticated using their email address, uid and etc.
Indicates whether to read groups from the LDAP.
Search base for groups.
The LDAP query used to search for groups.
The attribute to be treated as the group name.
Attribute that contains users.
If you wish to connect to external LDAP user store such that only the user entries are written to external LDAP and roles are not written to external LDAP, the only difference from the steps in section "Read-Only Mode" is in following:
How to Configure an External JDBC User Store
All Carbon based products can work with external RDBMSs. You can configure Carbon to read users/roles from your company RDBMS and even write to it. Therefore, the user core connected to two databases.
- Carbon database where authorization information is stored in the internal Carbon database.
- Your company database where users/roles resides.
So the user-mgt.xml file must contain details for two database connections. The connection details mentioned earlier is used by the Authorization manager. If we specify another set of database connection details inside UserStoreManager, it will read/write users to that database. Step by step guidelines for connecting to an external JDBC user store in read-only mode is given below.
Step 1 : Back-up the <carbon-home>/repository/conf/user-mgt.xml file. A sample file for JDBC user store (user-mgt-jdbc.xml) is available in <carbon-home>/repository/conf directory. Download the relevant file and save it as <IS_HOME>/repository/conf/user-mgt.xml. Uncomment the following section in your file if it is commented out.
Step 2 : Find a valid user that resides in the RDBMS. For example, say a valid username is AdminSOA. Update the Admin user section of your ldap configuration as follows. You don't have to update the password element; leave it as it is.
Step 3 : In user-mgt.xml file, add passwordHashMethod property within the JDBCUserStoreManager. For example,
The passwordHashMethod property specifies how the password should be stored, and usually has the values:
- SHA - Uses SHA digest method.
- MD5 - Uses MD 5 digest method.
- PLAIN_TEXT - Plain text passwords.
- In addition, it also supports all digest methods in http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest.html.
Step 4 : Update connection details inside <UserStoreManager> class.
Step 5 : In user-mgt.xml file, under realm configuration, set the value of MultiTenantRealmConfigBuilder property to org.wso2.carbon.user.core.config.multitenancy.SimpleRealmConfigBuilder. For example,
Step 6 : Add the JDBC driver to the classpath by dropping the jar to <carbon-home>/repository/components/lib directory.
Step 7 : Edit the SQLs in user-mgt.xml file according to your requirements, and start the server.