Java > LDAP > How to Query specific attributes of LDAP Entry
How to Query specific attributes of LDAP Entry
LDAP (Lightweight Directory Access Protocol) is based on X.500 standard.
Its a hierarchical data structure with Entries organized in a tree like structure
called Directory Information Tree (DIT).
The following example shows retrieving the specified attributes of all entries having
objectclass as 'person'. The attributes such as user role and password are not grouped
under default attributes. In such cases we have to explicitly specify the
list of attributes to be queried.
//Setup the environment to login as anonymous user
Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, "ldap://localhost:389/dc=test,dc=com");