This article describes how specific LDAP attributes can be ignored during LDAP user import.
Sometimes, users may change some information on the Liferay Portal. When the next scheduled LDAP import is executed, it will overwrite the user-made change. To ensure the change is not overwritten, users can define which attributes are to be ignored in their portal-ext.properties file.
For a more exhaustive look, in PortalLDAPImporterImpl.java, under the function updateUser, a function call to UserLocalServiceUtil.updateUser contains the list of available attributes. Removing the prefixes "get" and "is" defines the attribute. For instances, getEmailAddress, the attribute would become "contact.EmailAddress"
. These attributes must be prefixed with "contact." The reason why "contact" must be added is because the property was registered in the bean as LDAPUser#contact.xxxxxx
.
Here is the function call with the attributes:
user = UserLocalServiceUtil.updateUser(
user.getUserId(), password, StringPool.BLANK, StringPool.BLANK,
passwordReset, ldapUser.getReminderQueryQuestion(),
ldapUser.getReminderQueryAnswer(), ldapUser.getScreenName(),
ldapUser.getEmailAddress(), ldapUser.getFacebookId(),
ldapUser.getOpenId(), ldapUser.getLanguageId(),
ldapUser.getTimeZoneId(), ldapUser.getGreeting(),
ldapUser.getComments(), ldapUser.getFirstName(),
ldapUser.getMiddleName(), ldapUser.getLastName(),
ldapUser.getPrefixId(), ldapUser.getSuffixId(), ldapUser.isMale(),
birthdayMonth, birthdayDay, birthdayYear, ldapUser.getSmsSn(),
ldapUser.getAimSn(), ldapUser.getFacebookSn(), ldapUser.getIcqSn(),
ldapUser.getJabberSn(), ldapUser.getMsnSn(),
ldapUser.getMySpaceSn(), ldapUser.getSkypeSn(),
ldapUser.getTwitterSn(), ldapUser.getYmSn(), ldapUser.getJobTitle(),
ldapUser.getGroupIds(), ldapUser.getOrganizationIds(),
ldapUser.getRoleIds(), ldapUser.getUserGroupRoles(),
ldapUser.getUserGroupIds(), ldapUser.getServiceContext())
Users are strongly discouraged from modifying the Java classes and methods.
Resolution
- In portal.properties, users can see which available attributes are listed within portal.properties:
Set the user attributes that are controlled from the portal. When adding # or updating a user from LDAP, these attributes will be skipped. # ldap.user.ignore.attributes= #ldap.user.ignore.attributes=aimSn,comments,facebookId,facebookSn,greeting,icqSn,jabberSn,jobTitle,languageId,msnSn,mySpaceSn,openId,prefixId,reminderQueryAnswer,reminderQueryQuestion,skypeSn,smsSn,suffixId,timeZoneId,twitterSn,ymSn
- Copy the property
ldap.user.ignore.attributes=
and copy it to the portal-ext.properties. - Add the properties to be ignored: e.g.
ldap.user.ignore.attributes=contact.EmailAddress
- Save the file.
- Start the Portal. During the next LDAP import, the LDAP process will ignore those attributes defined in the portal-ext.properties.