Commit 1b503466 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Now correctly filters for users matching the user search string.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1667 b35dd754-fafc-0310-a699-88a17e54d16e
parent 65c21a45
...@@ -41,7 +41,7 @@ public class LdapGroupProvider implements GroupProvider ...@@ -41,7 +41,7 @@ public class LdapGroupProvider implements GroupProvider
{ {
private LdapManager manager; private LdapManager manager;
private UserProvider userProvider; private UserManager userManager;
private int groupCount; private int groupCount;
private long expiresStamp; private long expiresStamp;
...@@ -52,7 +52,7 @@ public class LdapGroupProvider implements GroupProvider ...@@ -52,7 +52,7 @@ public class LdapGroupProvider implements GroupProvider
*/ */
public LdapGroupProvider() { public LdapGroupProvider() {
manager = LdapManager.getInstance(); manager = LdapManager.getInstance();
userProvider = UserManager.getUserProvider(); userManager = UserManager.getInstance();
groupCount = -1; groupCount = -1;
expiresStamp = System.currentTimeMillis(); expiresStamp = System.currentTimeMillis();
} }
...@@ -343,7 +343,12 @@ public class LdapGroupProvider implements GroupProvider ...@@ -343,7 +343,12 @@ public class LdapGroupProvider implements GroupProvider
} }
// Search for the dn based on the groupname. // Search for the dn based on the groupname.
answer = ctx.search("",searchFilter,new SearchControls()); SearchControls searchControls = new SearchControls();
String returnedAtts[]= { manager.getNameField(),
manager.getGroupDescriptionField(),
manager.getGroupMemberField() };
searchControls.setReturningAttributes(returnedAtts);
answer = ctx.search("",searchFilter,searchControls);
if (manager.isDebugEnabled()) { if (manager.isDebugEnabled()) {
Log.debug("... search finished"); Log.debug("... search finished");
...@@ -359,12 +364,10 @@ public class LdapGroupProvider implements GroupProvider ...@@ -359,12 +364,10 @@ public class LdapGroupProvider implements GroupProvider
while (answer.hasMoreElements()) while (answer.hasMoreElements())
{ {
String groupName = ""; String name = "";
try try
{ {
Attributes a = (((SearchResult)answer.next()).getAttributes()); Attributes a = (((SearchResult)answer.next()).getAttributes());
String name = ((String)((a.get(manager.getNameField())).get()));
groupName = name;
String description; String description;
try try
{ {
...@@ -390,17 +393,15 @@ public class LdapGroupProvider implements GroupProvider ...@@ -390,17 +393,15 @@ public class LdapGroupProvider implements GroupProvider
if (a1 != null) if (a1 != null)
userName = (String)a1.get(); userName = (String)a1.get();
} }
if (userName != null) try
{ {
try User user = userManager.getUser(userName);
{ members.add(user.getUsername());
members.add(JID.escapeNode(userName)); }
} catch (UserNotFoundException e)
catch (Exception e) {
{ if (manager.isDebugEnabled())
if (manager.isDebugEnabled()) Log.debug("User not found: "+userName);
Log.debug("Error loading user: "+userName,e);
}
} }
} }
Group g = new Group(this,name,description,members,new ArrayList<String>()); Group g = new Group(this,name,description,members,new ArrayList<String>());
...@@ -409,7 +410,7 @@ public class LdapGroupProvider implements GroupProvider ...@@ -409,7 +410,7 @@ public class LdapGroupProvider implements GroupProvider
catch (Exception e) catch (Exception e)
{ {
if (manager.isDebugEnabled()) if (manager.isDebugEnabled())
Log.debug("Error while populating group, "+groupName+".",e); Log.debug("Error while populating group, "+name+".",e);
} }
} }
if (manager.isDebugEnabled()) if (manager.isDebugEnabled())
......
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