In Linux Shell I use the following command to get all Distinguished Names (DN) in LDAP:
ldapsearch -x -b "" -H URL -D uid=administrator,cn=admins,cn=city -w PASS |grep dn:
My problem: How to get all DN's in Java as I did using the above command?
You can use the Java Naming and Directory Interface (JNDI).
Here is an example inspired from the linked tutorial :