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; if (!autoPassword) { String defaultPassword = PropsValues.LDAP_IMPORT_USER_PASSWORD_DEFAULT; if (defaultPassword.equalsIgnoreCase(_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()); if (ldapUser.isUpdatePortrait()) { byte[] portraitBytes = ldapUser.getPortraitBytes(); if ((portraitBytes != null) && (portraitBytes.length > 0)) { user = UserLocalServiceUtil.updatePortrait(user.getUserId(), portraitBytes); } } return user; }