I use code like this:
Attributes matchAttrs = new BasicAttributes(true);
matchAttrs.put(new BasiAttribute("mail", "admin@test.com"));
NamingEnumeration<SearchResult> answer = ctx.search(context, matchAttrs);
Where ctx
is of type InitialDirContext
, and context
is the search root (a context).