*/
public void setLDAPAttributes(Attributes attribs)
throws NamingException
{
Attribute attr;
String attrName;
// Set the User id.
attrName = LDAPSecurityConstants.getUserIdAttribute();
if (attrName != null)
{
attr = attribs.get(attrName);
if (attr != null && attr.get() != null)
{
try
{
setPrimaryKey(new StringKey(attr.get().toString()));
}
catch (Exception ex)
{
log.error("Exception caught:", ex);
}
}
}
// Set the Username.
attrName = LDAPSecurityConstants.getNameAttribute();
if (attrName != null)
{
attr = attribs.get(attrName);
if (attr != null && attr.get() != null)
{
setUserName(attr.get().toString());
}
}
else
{
log.error("There is no LDAP attribute for the username.");
}
// Set the Firstname.
attrName = LDAPSecurityConstants.getFirstNameAttribute();
if (attrName != null)
{
attr = attribs.get(attrName);
if (attr != null && attr.get() != null)
{
setFirstName(attr.get().toString());
}
}
// Set the Lastname.
attrName = LDAPSecurityConstants.getLastNameAttribute();
if (attrName != null)
{
attr = attribs.get(attrName);
if (attr != null && attr.get() != null)
{
setLastName(attr.get().toString());
}
}
// Set the E-Mail
attrName = LDAPSecurityConstants.getEmailAttribute();
if (attrName != null)
{
attr = attribs.get(attrName);
if (attr != null && attr.get() != null)
{
setEmail(attr.get().toString());
}
}
}