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")); }
final boolean sambaAccountsConfigured = isSambaAccountsConfigured(); if (posixAccountsConfigured == true || sambaAccountsConfigured == true) { final String no = LdapUtils.getAttributeStringValue(attributes, "uidNumber"); user.setUidNumber(NumberHelper.parseInteger(no)); final String no = LdapUtils.getAttributeStringValue(attributes, "gidNumber"); user.setGidNumber(NumberHelper.parseInteger(no)); user.setHomeDirectory(LdapUtils.getAttributeStringValue(attributes, "homeDirectory")); user.setLoginShell(LdapUtils.getAttributeStringValue(attributes, "loginShell")); final String sambaSID = LdapUtils.getAttributeStringValue(attributes, "sambaSID"); final Integer sambaSIDNumber = ldapConfig.getSambaAccountsConfig().getSambaSIDNumber(sambaSID); user.setSambaSIDNumber(sambaSIDNumber); final String sambaPrimaryGroupSID = LdapUtils.getAttributeStringValue(attributes, "sambaPrimaryGroupSID"); final Integer sambaPrimaryGroupSIDNumber = ldapConfig.getSambaAccountsConfig() .getSambaSIDNumber(sambaPrimaryGroupSID); user.setSambaPrimaryGroupSIDNumber(sambaPrimaryGroupSIDNumber); user.setSambaNTPassword(LdapUtils.getAttributeStringValue(attributes, "sambaNTPassword")); final String sambaPwdLastSet = LdapUtils.getAttributeStringValue(attributes, "sambaPwdLastSet"); if (sambaPwdLastSet != null) { final long value = NumberHelper.parseLong(sambaPwdLastSet) * 1000; // ms since 1970
/** * @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; }
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; }