• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do you get all Active Directory Groups  RSS feed

 
Brian Pembroke
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently writing a Java program to retrieve all the Active Directory groups. The code below is only return one group. I'm wanting all active dirctory groups.

I have posted my code below. Any help would be greatly appreciated.

public ActiveDirectoryGroup getGroup(DirContext ctx)
throws NamingException {
ActiveDirectoryGroup group = null;
SearchControls scope = new SearchControls();
scope.setTimeLimit(searchTimeLimit);
scope.setSearchScope(SearchControls.SUBTREE_SCOPE);
String base = (String) jndiEnv.get("AD_BASE_DN");
StringBuffer filterBuffer = new StringBuffer();
filterBuffer.append("(&(objectClass=group))");
if (jndiEnv.get("AD_GROUP_FILTER") != null)
filterBuffer.append((String) jndiEnv.get("AD_GROUP_FILTER"));
filterBuffer.append(")");
String filter = filterBuffer.toString();
NamingEnumeration result = ctx.search(base, filter, scope);
if (result.hasMore()) {
SearchResult srchResult = (SearchResult) result.next();
group = new ActiveDirectoryGroup(srchResult.getAttributes());
return group;
}

Thanks
[ June 13, 2007: Message edited by: Brian Pembroke ]
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's happening ?
Is it
- not compiling (show us the errors)
- not returning anything
- not returning the objects you were expecting
- throwing an exception
- something else ?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!