Connecting to Active Directory
ArrayList getListValues(){
// Connect to the Active Directory here or click here for Connection code
ArrayList list = new ArrayList();
SearchControls searchctrl = new SearchControls();
searchctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
searchctrl.setReturningAttributes(new String[]{"name or id"}); \\ attributes which we are retriving from AD
results = dirContext.search("", "(objectclass=user)", searchctrl);
while(results.hasMore()){
SearchResult res = (SearchResult) results.next();
Attributes attributes = res.getAttributes();
Enumeration attribute = attributes.getAll();
while(attribute.hasMoreElements()){
Attribute attr = (Attribute) attribute.nextElement();
if(!attr.toString().equals("") && !attr.toString().equals(null)){
list.add(attr.toString());
}
}
}
return list;
}
No comments:
Post a Comment