use of org.simbasecurity.core.domain.repository.GroupRepository in project simba-os by cegeka.
the class ActiveDirectoryLoginModule method addADGroupsToUser.
protected void addADGroupsToUser(LdapContext ldapContext, User user, String userCN) throws NamingException {
SearchControls searchControls = new SearchControls();
searchControls.setReturningAttributes(new String[] { "dn" });
searchControls.setSearchScope(searchScope);
GroupRepository groupRepository = GlobalContext.locate(GroupRepository.class);
String filterGroups = "(&(member=" + userCN + "," + searchBase + ")(objectcategory=group))";
NamingEnumeration results = ldapContext.search(searchBase, filterGroups, searchControls);
while (hasMoreResults(results)) {
String groupCN = ((SearchResult) results.next()).getName();
Group group = groupRepository.findByCN(groupCN);
if (group != null) {
user.addGroup(group);
}
}
}
Aggregations