Code example for SearchControls

Methods: setReturningAttributes

0
   * <code>objectClass=organizationalRole</code>, and returning the <code>cn</code> attribute.</li> 
   * </ul> 
   */ 
  @Test
  public void testGetAllAuthorities3() throws Exception {
    SearchControls con1 = new SearchControls();
    con1.setReturningAttributes( new String[] { "cn" } ); //$NON-NLS-1$
 
    LdapSearchParamsFactory paramsFactory =
        new LdapSearchParamsFactoryImpl( "ou=roles", "(objectClass=organizationalRole)", con1 ); //$NON-NLS-1$ //$NON-NLS-2$
 
    Transformer one = new SearchResultToAttrValueList( "cn" ); //$NON-NLS-1$
    Transformer two = new StringToGrantedAuthority();
    Transformer[] transformers = { one, two };
    Transformer transformer = new ChainedTransformer( transformers );
 
    LdapSearch rolesSearch = new GenericLdapSearch( getContextSource(), paramsFactory, transformer );
 
    SearchControls con2 = new SearchControls();
    con1.setReturningAttributes( new String[] { "cn" } ); //$NON-NLS-1$
 
    LdapSearchParamsFactory paramsFactory2 =
        new LdapSearchParamsFactoryImpl( "ou=groups", "(objectClass=groupOfUniqueNames)", con2 ); //$NON-NLS-1$//$NON-NLS-2$
 
    Transformer oneB = new SearchResultToAttrValueList( "cn" ); //$NON-NLS-1$
Contextual code suggestions in your IDE  Get Codota for Java