protected T mapToObject(final String dn, final String ouBase, final Attributes attributes) throws NamingException { String fullDn; if (StringUtils.isNotBlank(ouBase) == true) { fullDn = dn + "," + ouBase; } else { fullDn = dn; } final T obj = mapToObject(fullDn, attributes); obj.setDn(fullDn); obj.setOrganizationalUnit(LdapUtils.getOrganizationalUnit(dn, ouBase)); obj.setCommonName(LdapUtils.getAttributeStringValue(attributes, "cn")); obj.setObjectClasses(LdapUtils.getAttributeStringValues(attributes, "objectClass")); return obj; }
protected void mapToObject(final String dn, final LdapPerson person, final Attributes attributes) throws NamingException { person.setSurname(LdapUtils.getAttributeStringValue(attributes, "sn")); person.setGivenName(LdapUtils.getAttributeStringValue(attributes, "givenName")); person.setUid(LdapUtils.getAttributeStringValue(attributes, "uid")); person.setEmployeeNumber(LdapUtils.getAttributeStringValue(attributes, "employeeNumber")); person.setOrganization(LdapUtils.getAttributeStringValue(attributes, "o")); person.setMail(LdapUtils.getAttributeStringValues(attributes, "mail")); person.setDescription(LdapUtils.getAttributeStringValue(attributes, "description")); person.setTelephoneNumber(LdapUtils.getAttributeStringValue(attributes, "telephoneNumber")); person.setMobilePhoneNumber(LdapUtils.getAttributeStringValues(attributes, "mobile")); person.setHomePhoneNumber(LdapUtils.getAttributeStringValue(attributes, "homePhone")); }
/** * @see org.projectforge.business.ldap.LdapDao#mapToObject(java.lang.String, javax.naming.directory.Attributes) */ @Override protected LdapGroup mapToObject(final String dn, final Attributes attributes) throws NamingException { final LdapGroup group = new LdapGroup(); group.setBusinessCategory(LdapUtils.getAttributeStringValue(attributes, "businessCategory")); group.setDescription(LdapUtils.getAttributeStringValue(attributes, "description")); group.setOrganization(LdapUtils.getAttributeStringValue(attributes, "o")); final String[] members = LdapUtils.getAttributeStringValues(attributes, "uniqueMember"); if (members != null) { for (final String member : members) { group.addMember(member, ldapConfig.getBaseDN()); } } final boolean posixAccountsConfigured = ldapUserDao.isPosixAccountsConfigured(); if (posixAccountsConfigured == true) { final String no = LdapUtils.getAttributeStringValue(attributes, "gidNumber"); group.setGidNumber(NumberHelper.parseInteger(no)); } return group; }