private Collection getUserRoles ( String userName ) throws NamingException { log . debug ( "Obtaining roles for userName: " + userName ) ; // filter expression: all roles with uniqueMember matching user DN // (uniqueMember=cn=userName,dc=company,dc=com) String filter = "(" + roleMemberRDN + "=" + userNameRDN + "=" + userName + "," + userBase + ")" ; //search directory NamingEnumeration roleResults = this . search ( roleBase , filter , new String [ ] { roleMemberRDN } ) ; ArrayList results = new ArrayList ( ) ; while ( roleResults != null && roleResults . hasMore ( ) ) { SearchResult roleResult = ( SearchResult ) roleResults . next ( ) ; String roleResultName = roleResult . getName ( ) ; if ( "" . equals ( roleResultName ) ) { //logger.debug("ignoring empty result"); continue ; } String roleResultValue = ( roleResultName . split ( "=" ) ) [ 1 ] ; results . add ( roleResultValue ) ; } return results ; }
Get the collection of role names for the user