
I’m using netscape ldapsdk-4.1.jar,I am able to connect & authenticate with my ldap server :
try{
ldi.connect(hostname,LDAPv3.DEFAULT_PORT);
LDAPConnectionInfo.ldapSearchResults = ldi.search(LDAPConnectionInfo.MY_SEARCHBASE,LDAPConnectionInfo.MY_SCOPE,LDAPConnectionInfo.MY_FILTER,null,false);
System.out.println("Ldap Search Result : " +LDAPConnectionInfo.ldapSearchResults);
ldi.authenticate(3, "host", "****");
}
.....
Now I want fetch the data from :
- Under the domain component(dn, here=example.com) how many organizational units(ou) are there.
- For each organizational unit(ou) to get all common name(cn) and it’s leaf objects under the common name(cn).
I think I have to use some ldap query to fetch these data….any input will be highly appreciated.
Create a search request for each organizational unit where:
subtreeobjectClass=commonObjectClasswherecommonObjectCLassis an objectClass common to entries to be retrieved, orcn=*transmit each search request in turn to the LDAP directory server and interpret the responses.
Do not use the netscape code, it’s ancient, buggy, and slow. Use the UnboundID LDAP SDK instead