Commit 63b0a4f7 authored by Guus der Kinderen's avatar Guus der Kinderen

OF-1041: Revert "Fixed group population for colliding full names."

This reverts commit fb9c6a39.
Instead of the code change, Openfire should be configured with unique
identifiers in its system property 'ldap.usernameField'.
parent 69ede3dd
...@@ -227,7 +227,7 @@ public class LdapGroupProvider extends AbstractGroupProvider { ...@@ -227,7 +227,7 @@ public class LdapGroupProvider extends AbstractGroupProvider {
Pattern.compile("(?i)(^" + manager.getUsernameField() + "=)([^,]+)(.+)"); Pattern.compile("(?i)(^" + manager.getUsernameField() + "=)([^,]+)(.+)");
SearchControls searchControls = new SearchControls(); SearchControls searchControls = new SearchControls();
searchControls.setReturningAttributes(new String[] { "distinguishedName", manager.getUsernameField() }); searchControls.setReturningAttributes(new String[] { manager.getUsernameField() });
// See if recursive searching is enabled. Otherwise, only search one level. // See if recursive searching is enabled. Otherwise, only search one level.
if (manager.isSubTreeSearch()) { if (manager.isSubTreeSearch()) {
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
...@@ -283,18 +283,9 @@ public class LdapGroupProvider extends AbstractGroupProvider { ...@@ -283,18 +283,9 @@ public class LdapGroupProvider extends AbstractGroupProvider {
NamingEnumeration usrAnswer = ctx.search("", NamingEnumeration usrAnswer = ctx.search("",
userFilter.toString(), searchControls); userFilter.toString(), searchControls);
if (usrAnswer != null && usrAnswer.hasMoreElements()) { if (usrAnswer != null && usrAnswer.hasMoreElements()) {
SearchResult searchResult = null; Attribute usernameAttr = ((SearchResult)usrAnswer.next()).getAttributes().get(manager.getUsernameField());
// We may get multiple search results for the same user CN. if (usernameAttr != null) {
// Iterate through the entire set to find a matching distinguished name. username = (String)usernameAttr.get();
while(usrAnswer.hasMoreElements()) {
searchResult = (SearchResult) usrAnswer.nextElement();
Attributes attrs = searchResult.getAttributes();
Attribute userdnAttr = attrs.get("distinguishedName");
if (username.equals((String)userdnAttr.get())) {
// Exact match found, use it.
username = (String)attrs.get(manager.getUsernameField()).get();
break;
}
} }
} }
// Close the enumeration. // Close the enumeration.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment