List All Users from LDAP using JNDI

We  have already seen the fundamentals of JNDI  along with examples for Naming as well as Directory Services using JNDI. So far, all the  JNDI examples using LDAP were fetching/updating a particular user from the DIT. In this section we would list all the users from LDAP using JNDI in “ou=users,ou=system” in a generic way.

List All Users from LDAP using JNDI

The basic setup is same as that of the previous examples.We are using Apache Directory Studio as the LDAP provider .In this case we are searching the users details using the search() method of DirContext object.



The code shown here lists all the attributes of all users.This can be controlled by adding returning attributes to search controls .


String[] attributes = { “cn”, “employeeNumber”, “sn” };

JNDI Overview

JNDI example – Naming Service

JNDI example -Directory Service 

2 thoughts on “List All Users from LDAP using JNDI


    Not able to get all user. Its able to pull only 1000 records.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">