I'm using JNDI library to access to an AD from Java Webapp. I authenticate agaisnt the AD via LDAP using a technical user as follows:
Hashtable<String, String> ldapEnv = new Hashtable<String, String>(11);
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT);
ldapEnv.put(Context.PROVIDER_URL, providerUrl);
ldapEnv.put(Context.SECURITY_AUTHENTICATION,
SECURITY_AUTHENTICATION_SIMPLE);
ldapEnv.put(Context.SECURITY_PRINCIPAL, principal);
ldapEnv.put(Context.SECURITY_CREDENTIALS, credentials);
return new InitialDirContext(ldapEnv);
I use this user to read and write from/to AD.
But after that, I don't know how to authenticate the final user who is really accessing to my webapp with his user and a password.
I read about using find method from Context class but I'm not sure how to do or how to build the the search filter. For example
(&(cn= ....
I don't know either how to find for all users in the AD. I would like to show in my webapp a list of all available users in AD