我需要覆蓋portalLDAPImporterImpl.java
addUser()
方法以在從LDAP導入用戶並將其添加到Liferay後執行某些操作。我遵循這些步驟(Eclipse環境):通過ext插件對源代碼進行的Liferay更改不會發生
- 創建Ext插件項目名稱customLdap;
- 在文檔根目錄/ WEB-INF/EXT-IMPL/src目錄我創建了一個包名com.liferay.portal.security.ldap
- 在那裏,我創造我CustomPortalLDAPImporterImpl.java類擴展portalLDAPImporterImpl。的java並重寫方法ADDUSER
代碼提取物:
@Override
protected User addUser(long companyId, LDAPUser ldapUser, String password)
throws Exception {
if (_log.isDebugEnabled()) {
_log.debug("Adding user " + ldapUser.getEmailAddress());
}
boolean autoPassword = ldapUser.isAutoPassword();
if (!PropsValues.LDAP_IMPORT_USER_PASSWORD_ENABLED) {
autoPassword = PropsValues.LDAP_IMPORT_USER_PASSWORD_AUTOGENERATED
&& !PropsValues.AUTH_PIPELINE_ENABLE_LIFERAY_CHECK;
if (!autoPassword) {
String defaultPassword = PropsValues.LDAP_IMPORT_USER_PASSWORD_DEFAULT;
if (StringUtil.equalsIgnoreCase(defaultPassword,
_USER_PASSWORD_SCREEN_NAME)) {
defaultPassword = ldapUser.getScreenName();
}
password = defaultPassword;
}
}
Calendar birthdayCal = CalendarFactoryUtil.getCalendar();
birthdayCal.setTime(ldapUser.getBirthday());
int birthdayMonth = birthdayCal.get(Calendar.MONTH);
int birthdayDay = birthdayCal.get(Calendar.DAY_OF_MONTH);
int birthdayYear = birthdayCal.get(Calendar.YEAR);
User user = UserLocalServiceUtil.addUser(ldapUser.getCreatorUserId(),
companyId, autoPassword, password, password,
ldapUser.isAutoScreenName(), ldapUser.getScreenName(),
ldapUser.getEmailAddress(), 0, StringPool.BLANK,
ldapUser.getLocale(), ldapUser.getFirstName(),
ldapUser.getMiddleName(), ldapUser.getLastName(), 0, 0,
ldapUser.isMale(), birthdayMonth, birthdayDay, birthdayYear,
StringPool.BLANK, ldapUser.getGroupIds(),
ldapUser.getOrganizationIds(), ldapUser.getRoleIds(),
ldapUser.getUserGroupIds(), ldapUser.isSendEmail(),
ldapUser.getServiceContext());
_log.info("-----------------------------------------User||||Added----------------------------------------");
if (ldapUser.isUpdatePortrait()) {
byte[] portraitBytes = ldapUser.getPortraitBytes();
if (ArrayUtil.isNotEmpty(portraitBytes)) {
user = UserLocalServiceUtil.updatePortrait(user.getUserId(),
portraitBytes);
}
}
return user;
}
創建文件夾名稱META-INF在文檔根/ WEB-INF/EXT-IMPL/SRC
在META-INF創建的文件命名爲EXT-spring.xml用下面的代碼:
- 構建和發佈我的插件
- 複製從DIST文件夾中的customLdap-ext.war文件,並在我的Tomcat粘貼它部署文件夾
- 開始了我的服務器的舊配置加載任何日誌打印而新用戶從進口ldap
我在哪裏做錯了?
注:我使用的Liferay 6.2.0.1 CE-GA6
6.2.0.1 CE-GA6?你從哪裏得到的 - 從原始資料來看,它不存在。 6.2.5將是匹配「GA6」的版本,6.2.0是GA1。我從來沒有聽說過6.2.0.1 –