I want to use "IN" operator from SQL for writing LDAP query.
For ex: If I have a list of names called "NameList", I write the following SQL query
SELECT * FROM TABLENAME WHERE NAME IN "NameList"
How do I do write similar LDAP Query?
public static final String[] LDAP_ATTRIBUTE_IDS = {"displayName"};
LdapContext ldapContext = new InitialLdapContext(env, null); \\env has all
\\connection details
List NameList = new ArrayList<String>();
NameList.add("ABC");
NameList.add("XYZ");
NameList.add("LMN");
NamingEnumeration namingEnumeration = ldapContext.search("",
"(&(objectCategory=person)(objectclass=user)(|(sAMAccountName=XYZ)(sAMAccountName=LMN)(sAMAccountName=ABC)))", getSearchControls());
Attributes attrs = ((SearchResult) namingEnumeration.next()).getAttributes();
String value = attrs.get(LDAP_ATTRIBUTE_IDS);
Instead on adding XYZ,LMN and ABC using "|" operator I would Like to know if NameList can be used with "IN" operator.