String requestedDN = null;
LDAPConnection lc = getNewConnection(serverAddress, port, useSSL, connectionDN, connectionPassword);
if (lc == null) {
return null;
}
LDAPEntry entry = null;
try {
String searchFilter = "(&(objectClass=person)(sAMAccountName=" + username + "))";
String[] attrs = { LDAPConnection.NO_ATTRS };
// Search recursively, but don't return any attributes for found objects
LDAPSearchResults searchResults = lc.search(baseDN, LDAPConnection.SCOPE_SUB, searchFilter, attrs, true);
if (searchResults.hasMore()) {
// Re-read the object to get the attributes now
requestedDN = searchResults.next().getDN();
// List all props just for fun.. (TODO: Remove this..)
entry = lc.read(requestedDN);
if (entry != null) {
Iterator iter = entry.getAttributeSet().iterator();
while (iter.hasNext()) {
log.info(".. " + iter.next().toString().replaceAll("[^A-Za-z]", ""));
}
}
} else {