I have OU (say ou1) in AD server and it has a user (say user1). I want query all the users belong to a OU of AD directory server. I am trying as show below :
SearchControls ouctls = new SearchControls();
String[] ouattrIDs = {"displayname", "mail", "canonicalName", "memberOf","Users"};
ctls.setReturningAttributes(ouattrIDs);
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration ouanswer = ctx.search("dc=exam,dc=com","(objectclass=group)", ouctls);
and by these I am not find user attribute populated.
while (ouAnswer.hasMoreElements()) {
SearchResult rslt = (SearchResult) ouAnswer.next();
Attributes attrs = rslt.getAttributes();
//log.debug("Group attributes"+attrs.get("cn"));
System.out.println("gr-->"+attrs.toString());
Attribute temp = attrs.get("cn");
}
Can you please help me in finding user object under a OU.