in ldap/src/java/org/apache/fulcrum/security/ldap/LDAPUserManagerImpl.java [463:503]
public <T extends User> T getUserById(Object id) throws DataBackendException, UnknownEntityException
{
try
{
DirContext ctx = bindAsAdmin();
/*
* Define the search.
*/
String filter = "(" + this.ldapUserid + "=" + String.valueOf(id) + ")";
/*
* Create the default search controls.
*/
SearchControls ctls = new SearchControls();
NamingEnumeration<SearchResult> answer =
ctx.search(this.ldapBasesearch, filter, ctls);
if (answer.hasMore())
{
SearchResult sr = answer.next();
Attributes attribs = sr.getAttributes();
T ldapUser = getUserInstance();
setLDAPAttributes(ldapUser, attribs);
return ldapUser;
}
else
{
throw new UnknownEntityException("No user exists for the id "
+ String.valueOf(id));
}
}
catch (NamingException ex)
{
throw new DataBackendException(
"The LDAP server specified is unavailable", ex);
}
}