Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

hiddentrue

Note to writer- The following should be copied to the product pages before pulling the page contents:

...

User management functionality is provided by default in all WSO2 Carbon-based products and is configured in the user-mgt.xml file found in the <PRODUCT_HOME>/repository/conf

...

 directory. This

...

topic provides instructions on how to configure an external Active Directory as the primary user store for the WSO2 server

...

titleThe default User Store

...

,

...

Note that the RDBMS used in the default configuration can remain as the database used for storing Authorization information.

Follow the given steps to configure an external Active Directory as the primary user store:

Table of Contents
maxLevel3
minLevel3

Step 1: Setting up the external AD user store manager

Info
titleBefore you begin
  • If you create the user-mgt.xml file yourself, be sure to save it in the <PRODUCT_HOME>/repository/conf directory.
  • The class attribute for an external AD is <UserStoreManager class="org.wso2.carbon.user.core.ldap.ActiveDirectoryUserStoreManager">.

...

Enable the ActiveDirectoryUserStoreManager class in the <PRODUCT_HOME>/repository/conf/user-mgt.xml file by uncommenting the code. When it is enabled, the user manager reads/writes into the Active Directory user store. 

Note

Note that these configurations already exist in the user-mgt.xml file so you only need to uncomment them and make the appropriate adjustments. Also ensure that you comment out the configurations for other user stores which you are not using.

...

The default configuration for the external read/write user store in the user-mgt.xml file is as given below. Change the values according to your requirement. For more information about user store properties, see the related documentation.

Code Block
languagehtml/xml
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ActiveDirectoryUserStoreManager">
            <Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
            <Property name="defaultRealmName">WSO2.ORG</Property>
            <Property name="Disabled">false</Property>                                   
            <Property name="kdcEnabled">false</Property>
            <Property name="ConnectionURL">ldaps://10.100.1.100:636</Property> 
            <Property name="ConnectionName">CN=admin,CN=Users,DC=WSO2,DC=Com</Property>
            <Property name="ConnectionPassword">A1b2c3d4</Property>
	    	<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
            <Property name="UserSearchBase">CN=Users,DC=WSO2,DC=Com</Property>
            <Property name="UserEntryObjectClass">user</Property>
            <Property name="UserNameAttribute">cn</Property>
            <Property name="isADLDSRole">false</Property>
	    	<Property name="userAccountControl">512</Property>
            <Property name="UserNameListFilter">(objectClass=user)</Property>
	    	<Property name="UserNameSearchFilter">(&amp;(objectClass=user)(cn=?))</Property>
            <Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
            <Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
            <Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
	    	<Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
            <Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
	    	<Property name="ReadGroups">true</Property>
	    	<Property name="WriteGroups">true</Property>
	    	<Property name="EmptyRolesAllowed">true</Property>
            <Property name="GroupSearchBase">CN=Users,DC=WSO2,DC=Com</Property>
	    	<Property name="GroupEntryObjectClass">group</Property>
            <Property name="GroupNameAttribute">cn</Property>
            <Property name="SharedGroupNameAttribute">cn</Property>
            <Property name="SharedGroupSearchBase">ou=SharedGroups,dc=wso2,dc=org</Property>
            <Property name="SharedGroupEntryObjectClass">groups</Property>
            <Property name="SharedTenantNameListFilter">(object=organizationalUnit)</Property>
            <Property name="SharedTenantNameAttribute">ou</Property>
            <Property name="SharedTenantObjectClass">organizationalUnit</Property>
            <Property name="MembershipAttribute">member</Property>
            <Property name="GroupNameListFilter">(objectcategory=group)</Property>
	    	<Property name="GroupNameSearchFilter">(&amp;(objectClass=group)(cn=?))</Property>
            <Property name="UserRolesCacheEnabled">true</Property>
            <Property name="Referral">follow</Property>
	    	<Property name="BackLinksEnabled">true</Property>
            <Property name="MaxRoleNameListLength">100</Property>
            <Property name="MaxUserNameListLength">100</Property>
            <Property name="SCIMEnabled">false</Property>
</UserStoreManager>
Note

When working with Active Directory;

  • It is best to enable the GetAllRolesOfUserEnabled property in the AuthorizationManager as follows. See the documentation on configuring the Authorization Manager for more information.

    Code Block
    languagexml
    <AuthorizationManager class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
    	<Property name="AdminRoleManagementPermissions">/permission</Property>
    	<Property name="AuthorizationCacheEnabled">true</Property>
    	<Property name="GetAllRolesOfUserEnabled">true</Property>
    </AuthorizationManager>

    Although using the user store manager does not depend on this property, you must consider enabling this if there are any performance issues in your production environment. Enabling this property affects the performance when the user logs in. This depends on the users, roles and permission stats.
     

  • If you are using ldaps (secured) to connect to the Active Directory as shown in the example below, you need to import the certificate of Active Directory to the client-truststore.jks of the WSO2 product. See the topic on configuring keystores for information on how to add certificates to the trust-store.

    Code Block
    languagexml
    <Property name="ConnectionURL">ldaps://10.100.1.100:636</Property>

...

For Active Directory, you can use <Property name="Referral">follow</Property> to enable referrals within the user store. The AD user store may be partitioned into multiple domains. However, according to the use store configurations in the user-mgt.xml file, we are only connecting to one of the domains. Therefore, when a request for an object is received to the user store, the <Property name="Referral">follow</Property> property ensures that all the domains in the directory will be searched to locate the requested object.
 

...

Set the attribute to use as the username, typically either cn or uid for LDAP. Ideally, <Property name="UserNameAttribute"> and <Property name="UserNameSearchFilter"> should refer to the same attribute. If you are not sure what attribute is available in your user store, check with your LDAP/Active Directory administrator. 

Code Block
languagehtml/xml
<Property name="UserNameAttribute">sAMAccountName</Property>

...

  • Enable the ReadGroups property.

    Code Block
    languagehtml/xml
    <Property name="ReadGroups">true</Property>
  • Set the GroupSearchBase property to the directory name where the Roles are stored. That is, the roles you create using the management console of your product will be stored in this directory location. Also, when LDAP searches for users, it will start from this location of the directory. For example:

    Code Block
    languagehtml/xml
    <Property name="GroupSearchBase">ou=system,CN=Users,DC=wso2,DC=test</Property>
  • Set the GroupSearchFilter and GroupNameAttributes. For example:

    Code Block
    languagehtml/xml
    <Property name="GroupSearchFilter">(objectClass=groupOfNames)</Property>
    <Property name="GroupNameAttribute">cn</Property>
  • Set the MembershipAttribute property as shown below:

    Code Block
    languagehtml/xml
    <Property name="MembershipAttribute">member</Property> 

To read roles based on a backlink attribute, use the following code snipet instead of the above:

Code Block
languagehtml/xml
<Property name="ReadGroups">false</Property>
<Property name="GroupSearchBase">ou=system</Property>
<Property name="GroupSearchFilter">(objectClass=groupOfNames)</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="MembershipAttribute">member</Property>

<Property name="BackLinksEnabled">true</Property>
<Property name="MembershipOfAttribute">memberOf</Property> 

Step 2: Updating the system administrator

The admin user is the super tenant that will be able to manage all other users, roles and permissions in the system by using the management console of the product. Therefore, the user that should have admin permissions is required to be stored in the user store when you start the system for the first time. Since the Active Directory user store can be written to, you have the option of creating a new admin user in the user store when you start the system for the first time. Alternatively, you can also use a user ID that already exists in the user store. See the related documentation for more information about the system administrator.

These two alternative configurations can be done as explained below.

  • Find a valid user that already resides in the user store. For example, say a valid username is AdminSOA. Update the <AdminUser> section of your configuration as shown below. You do not have to update the password element as it is already set in the user store.

    Code Block
    languagehtml/xml
    <AddAdmin>False</AddAdmin> 
    <AdminRole>admin</AdminRole> 
    <AdminUser>
     <UserName>AdminSOA</UserName> 
     <Password>XXXXXX</Password> 
    </AdminUser>
  • Since the user store can be written to, you can add the super tenant user to the user store. Therefore, <AddAdmin> should be set to true as shown below.

    Code Block
    languagehtml/xml
    linenumberstrue
    <AddAdmin>true</AddAdmin> 
    <AdminRole>admin</AdminRole> 
    <AdminUser> 
     <UserName>admin</UserName> 
     <Password>admin</Password> 
    </AdminUser>

Step 3: Starting the server

Start your server and try to log in as the admin user you specified. 

Related Topics

...

hiddentrue

Note to writers: Add the following as links to the relevant documentation:

...

by changing the default configuration given in this file.

Include Page
Shared:Configuring a Read-Write Active Directory User Store (V3)
Shared:Configuring a Read-Write Active Directory User Store (V3)

 

...