@ Override public Set < Node > getUsersForGroup ( Node group ) { Set < Node > users = new TreeSet <> ( ) ; try { String query = "(" + groupIdentifyer + "=" + group . getName ( ) + ")" ; SearchResult searchResult ; Attributes attributes ; SearchControls controls = new SearchControls ( ) ; controls . setSearchScope ( SearchControls . SUBTREE_SCOPE ) ; NamingEnumeration < SearchResult > results = ctx . search ( "" , query , controls ) ; Node user ; while ( results . hasMore ( ) ) { searchResult = results . next ( ) ; attributes = searchResult . getAttributes ( ) ; NamingEnumeration < ? > members = attributes . get ( groupMemberAttribut ) . getAll ( ) ; while ( members . hasMoreElements ( ) ) { String memberDN = ( String ) members . nextElement ( ) ; String uid = getIdentifyerValueFromDN ( memberDN ) ; user = getUser ( uid ) ; user . setDn ( memberDN ) ; users . add ( user ) ; } } } catch ( NamingException ex ) { handleNamingException ( group , ex ) ; } return users ; }
Load all Users for a given Group .