WSO2 external ldap not working

2019-05-30 00:27发布

I edited the user-mgt.xml to try and connect to a newly installed Apache DS LDAP.

I created an ldap user person object in apache ds ldap located at: cn=admin,ou=users,o=southpark

I tried READ ONLY section:

 <UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager">
        <Property name="ReadOnly">true</Property>
        <-Property name="MaxUserNameListLength">100</Property>
        <Property name="ConnectionURL">ldap://localhost:10389</Property>
        <Property name="ConnectionName">cn=admin,ou=users,o=acme</Property>
        <Property name="ConnectionPassword">admin</Property>
        <Property name="UserSearchBase">ou=users,o=acme</Property>
        <Property name="UserNameListFilter">(objectClass=person)</Property>
        <Property name="UserNameAttribute">cn</Property>
        <Property name="ReadLDAPGroups">false</Property>
        <Property name="GroupSearchBase">ou=groups,o=acme</Property>
        <Property name="GroupNameListFilter">(objectClass=groupOfNames)</Property>
        <Property name="GroupNameAttribute">cn</Property>
        <Property name="MembershipAttribute">member</Property>
        <Property name="UserRolesCacheEnabled">true</Property>
        <Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
        <Property name="maxFailedLoginAttempt">0</Property>
    </UserStoreManager>

...and get the following stack trace:

[2013-02-06 04:33:23,905]  INFO {org.wso2.carbon.databridge.agent.thrift.internal.AgentDS}
-  Successfully deployed Agent Client
[2013-02-06 04:33:24,896]  WARN {net.sf.ehcache.config.ConfigurationFactory} 
-  No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the
   classpath: bundleresource://36.fwk1434669784/ehcache-failsafe.xml
[Fatal Error] :106:7: The content of elements must consist of well-formed character data or markup.
[2013-02-06 04:33:24,965] ERROR {org.wso2.carbon.user.core.internal.Activator} -  Cannot start User Manager Core bundle
org.wso2.carbon.user.core.UserStoreException: Error in building Document
        at org.wso2.carbon.user.core.common.DefaultRealmService.getConfigurationElement(DefaultRealmService.java:249)
        ....... 20 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 106; columnNumber: 7; The content of elements must consist of well-formed character data or markup.
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
        at org.wso2.carbon.utils.CarbonUtils.replaceSystemVariablesInXml(CarbonUtils.java:1035)
        ... 21 more

I also tried the read-write external ldap connection:

<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager">
        <Property name="ConnectionURL">ldap://localhost:10389</Property>
        <Property name="ConnectionName">cn=admin,ou=users,o=acme</Property>
        <Property name="ConnectionPassword">admin</Property>
        <Property name="passwordHashMethod">SHA</Property>
        <Property name="UserNameListFilter">(objectClass=person)</Property>
        <Property name="UserEntryObjectClass">inetOrgPerson</Property>
        <Property name="UserSearchBase">ou=users,o=acme</Property>
        <Property name="UserNameSearchFilter">(&amp;(objectClass=person)(uid=?))</Property>
        <Property name="UserNameAttribute">cn</Property>
        <Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
        <Property name="UsernameJavaScriptRegEx">^[\\S]{3,30}$</Property>
        <Property name="RolenameJavaScriptRegEx">^[\\S]{3,30}$</Property>
        <Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
        <Property name="PasswordJavaScriptRegEx">^[\\S]{5,30}$</Property>
        <Property name="ReadLDAPGroups">true</Property>
        <Property name="WriteLDAPGroups">true</Property>
        <Property name="EmptyRolesAllowed">false</Property>
        <Property name="GroupSearchBase">ou=groups,o=acme</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="MembershipAttribute">member</Property>
        <Property name="UserRolesCacheEnabled">true</Property>
        <Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
        <Property name="maxFailedLoginAttempt">0</Property>
    </UserStoreManager>

...and i get the following exception around non-existent user:

[2013-02-06 05:36:13,142]  INFO {org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager} -  LDAP connection created successfully in read-write mode
[2013-02-06 05:36:13,175] ERROR {org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager} -  There is no user with the user name: wso2.anonymous.user to be added to this role.
[2013-02-06 05:36:13,176] ERROR {org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager} -  Role: wso2.anonymous.rolecould not be added.
org.wso2.carbon.user.core.UserStoreException: There is no user with the user name: wso2.anonymous.user to be added to this role.
        at org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager.doAddRole(ReadWriteLDAPUserStoreManager.java:1014)
        at org.wso2.carbon.user.core.common.AbstractUserStoreManager.addRole(AbstractUserStoreManager.java:1246)
        at org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager.addInitialData(ReadWriteLDAPUserStoreManager.java:1834)

Getting worried about quality, if out of the box installs are not easy to connect to each other...

Thanks for any assists...

2条回答
干净又极端
2楼-- · 2019-05-30 00:34

If you look at your first exception - it's an xml parsing issue.

Caused by: org.xml.sax.SAXParseException; lineNumber: 106; columnNumber: 7; The content of elements must consist of well-formed character data or markup.

Please have a look at the line number given in the error.

查看更多
放我归山
3楼-- · 2019-05-30 00:49

It's just a malformed XML file. You've wrong the following line:

<-Property name="MaxUserNameListLength">100</Property>

Remove the dash

<Property name="MaxUserNameListLength">100</Property>
查看更多
登录 后发表回答