Code example for SearchControls

Methods: setReturningAttributes

0
   * <code>objectClass=groupOfUniqueNames</code>, and extracting the <code>uid</code> token of the 
   * <code>uniqueMember</code> attribute. 
   */ 
  @Test
  public void testGetAllUserNames1() throws Exception {
    SearchControls con1 = new SearchControls();
    con1.setReturningAttributes( new String[] { "uniqueMember" } ); //$NON-NLS-1$
 
    LdapSearchParamsFactoryImpl paramFactory =
        new LdapSearchParamsFactoryImpl( "ou=groups", "(objectClass=groupOfUniqueNames)", con1 ); //$NON-NLS-1$//$NON-NLS-2$
    paramFactory.afterPropertiesSet();
 
    Transformer transformer1 = new SearchResultToAttrValueList( "uniqueMember", "uid" ); //$NON-NLS-1$ //$NON-NLS-2$
 
    GenericLdapSearch allUsernamesSearch = new GenericLdapSearch( getContextSource(), paramFactory, transformer1 );
    allUsernamesSearch.afterPropertiesSet();
 
    DefaultLdapUserRoleListService userRoleListService = new DefaultLdapUserRoleListService();
 
    userRoleListService.setAllUsernamesSearch( allUsernamesSearch );
Experience pair programming with AI  Get Codota for Java