Advertisement
Guest User

Untitled

a guest
Nov 8th, 2013
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. @RunWith(FrameworkRunner.class)
  2. @CreateLdapServer(
  3.         transports =
  4.                 {
  5.                         @CreateTransport(protocol = "LDAP")
  6.                 })
  7. public class SearchTests extends AbstractLdapTestUnit {
  8.     public static LdapServer ldapServer;
  9.  
  10.     @Test
  11.     public void testSearchAllAttrs() throws Exception {
  12.         LdapContext ctx = (LdapContext) getWiredContext(ldapServer, null).lookup("ou=system");
  13.  
  14.         SearchControls controls = new SearchControls();
  15.         controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
  16.         controls.setReturningAttributes(new String[]
  17.                 {"+", "*"});
  18.  
  19.         NamingEnumeration<SearchResult> res = ctx.search("", "(ObjectClass=*)", controls);
  20.  
  21.         assertTrue(res.hasMore());
  22.  
  23.         while (res.hasMoreElements()) {
  24.             SearchResult result = (SearchResult) res.next();
  25.  
  26.             System.out.println(result.getName());
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement