Versions Compared

Key

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

...

...

...

Info
titleThe default User Store

The primary user store that internal H2 database is configured by default in the user-mgt.xml file of WSO2 products is a JDBC user store, which reads/writes into the internal database of the product server. By default, the internal database is H2. This database is as the default primary user store. This internal database is used by the Authorization Manager (for user authentication information) as well as the User Store Manager (for defining users and roles). In the case of the WSO2 Identity Server, the default user store is an LDAP (Apache DS) that is shipped with the product.

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

...

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 a read-write LDAP is <UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager"> 

...

  1. Enable the <ReadWriteLDAPUserStoreManager> user store manager class in the user-mgt.xml file by uncommenting the relevant code. When it is enabled, the user manager reads/writes into the LDAP 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 that you are not using; in short, you can only configure one primary user store.

  2. The default configuration for the external read/write user store in the user-mgt.xml file is as follows. You may have to change some of these values according to your requirements. For more information about each of the properties used in the user-mgt.xml file for configuring the primary user store, see Properties of User Stores

    Code Block
    languagehtml/xml
    <UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager">
       <Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
       <Property name="ConnectionURL">ldap://localhost:${Ports.EmbeddedLDAP.LDAPServerPort}</Property>
       <Property name="ConnectionName">uid=admin,ou=system</Property>
       <Property name="ConnectionPassword">admin</Property>
       <Property name="PasswordHashMethod">SHA</Property>
       <Property name="UserNameListFilter">(objectClass=person)</Property>
       <Property name="UserEntryObjectClass">wso2Person</Property>
       <Property name="UserSearchBase">ou=Users,dc=wso2,dc=org</Property>
       <Property name="UserNameSearchFilter">(&amp;(objectClass=person)(uid=?))</Property>
       <Property name="UserNameAttribute">uid</Property>
       <Property name="PasswordJavaScriptRegEx">[\\S]{5,30}</Property>
       <Property name="UsernameJavaScriptRegEx">[\\S]{3,30}</Property>
       <Property name="UsernameJavaRegEx">[a-zA-Z0-9._\-|/]{3,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">ou=Groups,dc=wso2,dc=org</Property>
       <Property name="GroupNameListFilter">(objectClass=groupOfNames)</Property>
       <Property name="GroupEntryObjectClass">groupOfNames</Property>
       <Property name="GroupNameSearchFilter">(&amp;(objectClass=groupOfNames)(cn=?))</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="LDAPConnectionTimeout">5000</Property>
       <Property name="UserRolesCacheEnabled">true</Property>
       <Property name="UserDNPattern">uid={0},ou=Users,dc=wso2,dc=org</Property>
    </UserStoreManager>
    1. To read and write to an LDAPuserstore, it is important to ensure that the ReadGroups and WriteGroups properties in the <PRODUCT_HOME>/repository/conf/user-mgt.xml file are set to true.

      Code Block
      languagexml
      <Property name="ReadGroups">true</Property>
      <Property name="WriteGroups">true</Property>
    2. 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 administrator. 

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

      Specify the following properties that are relevant to connecting to the LDAP in order to perform various tasks.

      Code Block
      languagexml
      <Property name="ConnectionURL">ldap://localhost:${Ports.EmbeddedLDAP.LDAPServerPort}</Property>
      <Property name="ConnectionName">uid=admin,ou=system</Property>
      <Property name="ConnectionPassword">admin</Property>
    3. Note

      If you are using ldaps (secured LDAP) to connect to the LDAP:

      • You need set the ConnectionURL as shown below.

        Code Block
        languagexml
        <Property name="ConnectionURL">ldaps://10.100.1.100:636</Property>
      • You also need to enable connection pooling for LDAPS connections at the time of starting your server, which will enhance server performance.

        Specify the following properties that are relevant to connecting to the LDAP in order to perform various tasks.

        Code Block
        languagexml
        <Property name="ConnectionURL">ldap://localhost:${Ports.EmbeddedLDAP.LDAPServerPort}</Property>
        <Property name="ConnectionName">uid=admin,ou=system</Property>
        <Property name="ConnectionPassword">admin</Property>
    4. In WSO2 products based on Carbon 4.4.x, you can set the LDAPConnectionTimeout property: If the connection to the LDAP is inactive for the length of time (in milliseconds) specified by this property, the connection will be terminated.

    5. Set the ReadGroups property to 'true', if it should be allowed to read roles from this user store. When this property is 'true', you must also specify values for the GroupSearchBaseGroupSearchFilter and GroupNameAttribute properties. If the ReadGroups property is set to 'false', only Users can be read from the user store. You can set the configuration to read roles from the user store by reading the user/role mapping based on a membership (user list) or backlink attribute as shown below.

      To read the user/role mapping based on a membership (This is used by the ApacheDirectory server and OpenLDAP)

      • 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 EI profile will be stored in this directory location. Also, when LDAP searches for groups, 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 andGroupNameAttributes. 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 thefollowingcodesnipetinsteadofthe the following code snippet 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> 

...

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 productEI profile. 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 LDAP 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 LDAP. For information about the system administrator user, see Configuring the System Administrator. 

These two alternative configurations can be done as explained below.

...