Quote:
| Originally Posted by pritamc Hai rajds,
I am Pritam working in Java/J2EE. I would be very thankful if you can send me the code to access atleast 1000 records from the Active Directory. I am not able to do that and my sir wants me to do it in 3 days. Please help.
Thanks in advance.
Pritam. |
String[] ATTRS = {"uid"};
LDAPSearchConstraints ldapscon = ldapConnection.getSearchConstraints();
try {
ldapscon.setMaxResults(0);
flag = true;
String base = "ou=some,dc=company,dc=in";
//Search to the LDAP Server for given attributes
LDAPSearchResults ldapResultSet = ldapConnection.search(base, LDAPv2.SCOPE_SUB, null, ATTRS, false, ldapscon);
// Loop on results until complete
int count = 1;
//System.out.println("ResultSet Count::"+ldapResultSet.getCount());
while (ldapResultSet.hasMoreElements()) {
flag = false;
LDAPEntry ldapEntry = ldapResultSet.next();
System.out.println("LdapEntry::" + ldapEntry.getDN());
LDAPAttributeSet entryAttributeSet = ldapEntry.getAttributeSet();
Enumeration<LDAPAttribute> attributesInEntry = entryAttributeSet.getAttributes();
while (attributesInEntry.hasMoreElements()) {
LDAPAttribute currenrAttribute = attributesInEntry.nextElement();
Enumeration<String> valsInCurrentAttributes = currenrAttribute.getStringValues();
while (valsInCurrentAttributes.hasMoreElements()) {
String rdn = valsInCurrentAttributes.nextElement();
system.out.println("Rdn----"+rdn);
}
}
}
Ravi