Index: portal-impl/classes/content/Language.properties =================================================================== --- portal-impl/classes/content/Language.properties (revision 11286) +++ portal-impl/classes/content/Language.properties (working copy) @@ -1294,6 +1294,7 @@ group-mapping=Group Mapping group-name=Group Name group=Group +group-transformer=Group Atribute Transformer groups-and-roles=Groups and Roles groups-dn=Groups DN groups=Groups @@ -2990,6 +2991,7 @@ user-profile=User Profile user-ranks=User Ranks user=User +user-transformer=User Attribute Transformer users-dn=Users DN users=Users vacation-message=Vacation Message Index: portal-impl/src/com/liferay/portal/security/ldap/PortalLDAPUtil.java =================================================================== --- portal-impl/src/com/liferay/portal/security/ldap/PortalLDAPUtil.java (revision 11286) +++ portal-impl/src/com/liferay/portal/security/ldap/PortalLDAPUtil.java (working copy) @@ -30,6 +30,8 @@ import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogUtil; import com.liferay.portal.kernel.util.CalendarFactoryUtil; +import com.liferay.portal.kernel.util.ClassUtil; +import com.liferay.portal.kernel.util.InstancePool; import com.liferay.portal.kernel.util.PropertiesUtil; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; @@ -47,6 +49,7 @@ import com.liferay.util.ldap.LDAPUtil; import com.liferay.util.ldap.Modifications; +import java.lang.reflect.InvocationTargetException; import java.util.Calendar; import java.util.List; import java.util.Locale; @@ -64,6 +67,8 @@ import javax.naming.ldap.InitialLdapContext; import javax.naming.ldap.LdapContext; +import org.apache.commons.beanutils.MethodUtils; + /** * View Source * @@ -430,10 +435,12 @@ LogUtil.debug(_log, groupMappings); + Attributes _attrs = _transformAttributes(PropsUtil.LDAP_IMPORT_GROUP_TRANSFORMER, companyId, ctx, attrs); + String groupName = LDAPUtil.getAttributeValue( - attrs, groupMappings.getProperty("groupName")).toLowerCase(); + _attrs, groupMappings.getProperty("groupName")).toLowerCase(); String description = LDAPUtil.getAttributeValue( - attrs, groupMappings.getProperty("description")); + _attrs, groupMappings.getProperty("description")); // Get or create user group @@ -472,7 +479,7 @@ // Import users and membership if (importGroupMembership && (userGroup != null)) { - Attribute attr = attrs.get(groupMappings.getProperty("user")); + Attribute attr = _attrs.get(groupMappings.getProperty("user")); if (attr != null){ _importUsersAndMembershipFromLDAPGroup( @@ -502,24 +509,26 @@ updatePassword = false; } + Attributes _attrs = _transformAttributes(PropsUtil.LDAP_IMPORT_USER_TRANSFORMER, companyId, ctx, attrs); + long creatorUserId = 0; boolean passwordReset = false; boolean autoScreenName = false; String screenName = LDAPUtil.getAttributeValue( - attrs, userMappings.getProperty("screenName")).toLowerCase(); + _attrs, userMappings.getProperty("screenName")).toLowerCase(); String emailAddress = LDAPUtil.getAttributeValue( - attrs, userMappings.getProperty("emailAddress")); + _attrs, userMappings.getProperty("emailAddress")); Locale locale = defaultUser.getLocale(); String firstName = LDAPUtil.getAttributeValue( - attrs, userMappings.getProperty("firstName")); + _attrs, userMappings.getProperty("firstName")); String middleName = LDAPUtil.getAttributeValue( - attrs, userMappings.getProperty("middleName")); + _attrs, userMappings.getProperty("middleName")); String lastName = LDAPUtil.getAttributeValue( - attrs, userMappings.getProperty("lastName")); + _attrs, userMappings.getProperty("lastName")); if (Validator.isNull(firstName) || Validator.isNull(lastName)) { String fullName = LDAPUtil.getAttributeValue( - attrs, userMappings.getProperty("fullName")); + _attrs, userMappings.getProperty("fullName")); String[] names = LDAPUtil.splitFullName(fullName); @@ -535,7 +544,7 @@ int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = LDAPUtil.getAttributeValue( - attrs, userMappings.getProperty("jobTitle")); + _attrs, userMappings.getProperty("jobTitle")); long[] organizationIds = new long[0]; boolean sendEmail = false; @@ -634,7 +643,7 @@ String userMappingsGroup = userMappings.getProperty("group"); if (userMappingsGroup != null) { - Attribute attr = attrs.get(userMappingsGroup); + Attribute attr = _attrs.get(userMappingsGroup); if (attr != null){ _importGroupsAndMembershipFromLDAPUser( @@ -646,6 +655,35 @@ return user; } + private static Attributes _transformAttributes(String transClassProp, long companyId, LdapContext ctx, + Attributes attrs) throws PortalException, SystemException { + + String transImpl = PrefsPropsUtil.getString(companyId, transClassProp); + if (Validator.isNull(transImpl)) { + return attrs; + } + try { + String[] transNames = transImpl.split(":"); + String clsName = transNames[0]; + String methodName = transNames[1]; + Object transformer = InstancePool.get(clsName); + Object newAttrs = MethodUtils.invokeExactMethod(transformer, methodName, + new Object[] { + Long.valueOf(companyId), + ctx, + attrs}, + new Class[] { + Long.class, + LdapContext.class, + Attributes.class} + ); + + return (Attributes) newAttrs; + } catch (Exception e) { + throw new PortalException(e); + } + } + public static boolean isAuthEnabled(long companyId) throws PortalException, SystemException { Index: portal-impl/src/com/liferay/portal/util/PropsUtil.java =================================================================== --- portal-impl/src/com/liferay/portal/util/PropsUtil.java (revision 11286) +++ portal-impl/src/com/liferay/portal/util/PropsUtil.java (working copy) @@ -379,6 +379,10 @@ public static final String LDAP_ERROR_USER_LOCKOUT = "ldap.error.user.lockout"; + public static final String LDAP_IMPORT_USER_TRANSFORMER = "ldap.import.user.transformer"; + + public static final String LDAP_IMPORT_GROUP_TRANSFORMER = "ldap.import.group.transformer"; + // CAS public static final String CAS_AUTH_ENABLED = "cas.auth.enabled"; Index: portal-web/docroot/html/portlet/enterprise_admin/authentication_ldap.jsp =================================================================== --- portal-web/docroot/html/portlet/enterprise_admin/authentication_ldap.jsp (revision 11286) +++ portal-web/docroot/html/portlet/enterprise_admin/authentication_ldap.jsp (working copy) @@ -583,18 +583,16 @@ - - - - - - - - - - + + + + + + + + @@ -609,6 +607,22 @@ + + + + + + + + + + + + + + + +