分享

liferay ldap配置与相关代码

 荷露叮咚 2009-03-08

1.下载LDAP server 并安装, liferay支持如下的server,推荐使用apacheds,或openLDAP


 

2.下载一个LDAP客户端工具,官方网站都有提供 ,推荐使用 jxplorer,测试能否正常连接。

 

3. Enterprise Admin->setting->authentication->LDAP,Enable使用LDAP验证,Required是否必须通过LDAP验证,如果不勾选通过liferay验证即可。


Ldap验证代码代码 复制代码
  1. /**   
  2.  * LDAP验证   
  3.  * @param companyId   
  4.  * @param emailAddress   
  5.  * @param screenName   
  6.  * @param userId   
  7.  * @param password   
  8.  * @return   
  9.  * @throws Exception   
  10.  */   
  11. protected int authenticate(   
  12.         long companyId, String emailAddress, String screenName, long userId,   
  13.         String password)   
  14.     throws Exception {   
  15.     //是否需要LDAP验证   
  16.     if (!PortalLDAPUtil.isAuthEnabled(companyId)) {   
  17.         if (_log.isDebugEnabled()) {   
  18.             _log.debug("Authenticator is not enabled");   
  19.         }   
  20.   
  21.         return SUCCESS;   
  22.     }   
  23.   
  24.     if (_log.isDebugEnabled()) {   
  25.         _log.debug("Authenticator is enabled");   
  26.     }   
  27.   
  28.     // Make exceptions for omniadmins so that if they break the LDAP   
  29.     // configuration, they can still login to fix the problem   
  30.     //如果此用户是管理员的角色就返回成功   
  31.     if (authenticateOmniadmin(companyId, emailAddress, userId) == SUCCESS) {   
  32.         return SUCCESS;   
  33.     }   
  34.     //相对DN   
  35.     String baseDN = PrefsPropsUtil.getString(   
  36.         companyId, PropsUtil.LDAP_BASE_DN);   
  37.   
  38.     LdapContext ctx = PortalLDAPUtil.getContext(companyId);   
  39.   
  40.     if (ctx == null) {   
  41.         //查看LDAP验证是否是必须的   
  42.         return authenticateRequired(   
  43.             companyId, userId, emailAddress, FAILURE);   
  44.     }   
  45.   
  46.     //  Process LDAP auth search filter   
  47.   
  48.     String filter = PortalLDAPUtil.getAuthSearchFilter(   
  49.         companyId, emailAddress, screenName, String.valueOf(userId));   
  50.   
  51.     try {   
  52.         SearchControls cons = new SearchControls(   
  53.             SearchControls.SUBTREE_SCOPE, 10, null, false, false);   
  54.   
  55.         NamingEnumeration<SearchResult> enu = ctx.search(   
  56.             baseDN, filter, cons);   
  57.   
  58.         if (enu.hasMore()) {   
  59.             if (_log.isDebugEnabled()) {   
  60.                 _log.debug("Search filter returned at least one result");   
  61.             }   
  62.   
  63.             SearchResult result = enu.next();   
  64.   
  65.             String fullUserDN = PortalLDAPUtil.getNameInNamespace(   
  66.                 companyId, result);   
  67.   
  68.             Attributes attrs = PortalLDAPUtil.getAttributes(   
  69.                 ctx, fullUserDN);   
  70.   
  71.             LDAPAuthResult ldapAuthResult = authenticate(   
  72.                 ctx, companyId, attrs, fullUserDN, password);   
  73.   
  74.             // Process LDAP failure codes   
  75.   
  76.             String errorMessage = ldapAuthResult.getErrorMessage();   
  77.   
  78.             if (errorMessage != null) {   
  79.                 if (errorMessage.indexOf(PrefsPropsUtil.getString(   
  80.                         companyId, PropsUtil.LDAP_ERROR_USER_LOCKOUT))   
  81.                             != -1) {   
  82.   
  83.                     throw new UserLockoutException();   
  84.                 }   
  85.                 else if (errorMessage.indexOf(PrefsPropsUtil.getString(   
  86.                     companyId, PropsUtil.LDAP_ERROR_PASSWORD_EXPIRED))   
  87.                         != -1) {   
  88.   
  89.                     throw new PasswordExpiredException();   
  90.                 }   
  91.             }   
  92.   
  93.             if (!ldapAuthResult.isAuthenticated()) {   
  94.                 //查看LDAP验证是否是必须的   
  95.                 return authenticateRequired(   
  96.                     companyId, userId, emailAddress, FAILURE);   
  97.             }   
  98.   
  99.             // Get user or create from LDAP   
  100.   
  101.             User user = PortalLDAPUtil.importLDAPUser(   
  102.                 companyId, ctx, attrs, password, true);   
  103.   
  104.             // Process LDAP success codes   
  105.   
  106.             String resultCode = ldapAuthResult.getResponseControl();   
  107.   
  108.             if (resultCode.equals(LDAPAuth.RESULT_PASSWORD_RESET)) {   
  109.                 UserLocalServiceUtil.updatePasswordReset(   
  110.                     user.getUserId(), true);   
  111.             }   
  112.             else if (   
  113.                 resultCode.equals(LDAPAuth.RESULT_PASSWORD_EXP_WARNING)) {   
  114.   
  115.                 UserLocalServiceUtil.updatePasswordReset(   
  116.                     user.getUserId(), true);   
  117.             }   
  118.         }   
  119.         else {   
  120.             if (_log.isDebugEnabled()) {   
  121.                 _log.debug("Search filter did not return any results");   
  122.             }   
  123.             //查看LDAP验证是否是必须的   
  124.             return authenticateRequired(   
  125.                 companyId, userId, emailAddress, DNE);   
  126.         }   
  127.     }   
  128.     catch (Exception e) {   
  129.         _log.error("Problem accessing LDAP server: " + e.getMessage());   
  130.         //查看LDAP验证是否是必须的   
  131.         if (authenticateRequired(   
  132.                 companyId, userId, emailAddress, FAILURE) == FAILURE) {   
  133.   
  134.             throw e;   
  135.         }   
  136.     }   
  137.     finally {   
  138.         ctx.close();   
  139.     }   
  140.   
  141.     return SUCCESS;   
  142. }  
 

4.Default Values选择你使用的DS服务

 

5.测试连接能否成功。这些参数要根据自已的服务来填写。

测试成功

Ldap连接代码代码 复制代码
  1. /**   
  2.  * 获得连接上下文   
  3.  * @param companyId   
  4.  * @return   
  5.  * @throws Exception   
  6.  */   
  7. public static LdapContext getContext(long companyId) throws Exception {   
  8.     //连接地址(优先取数据库中)   
  9.     String baseProviderURL = PrefsPropsUtil.getString(   
  10.         companyId, PropsUtil.LDAP_BASE_PROVIDER_URL);   
  11.     //用户地址(优先取数据库中)   
  12.     String pricipal = PrefsPropsUtil.getString(   
  13.         companyId, PropsUtil.LDAP_SECURITY_PRINCIPAL);   
  14.     //连接密码(优先取数据库中)   
  15.     String credentials = PrefsPropsUtil.getString(   
  16.         companyId, PropsUtil.LDAP_SECURITY_CREDENTIALS);   
  17.   
  18.     return getContext(companyId, baseProviderURL, pricipal, credentials);   
  19. }   
  20.   
  21. public static LdapContext getContext(   
  22.         long companyId, String providerURL, String pricipal,   
  23.         String credentials)   
  24.     throws Exception {   
  25.   
  26.     Properties env = new Properties();   
  27.   
  28.     env.put(   
  29.         Context.INITIAL_CONTEXT_FACTORY,   
  30.         PrefsPropsUtil.getString(   
  31.             companyId, PropsUtil.LDAP_FACTORY_INITIAL));   
  32.     env.put(Context.PROVIDER_URL, providerURL);   
  33.     env.put(Context.SECURITY_PRINCIPAL, pricipal);   
  34.     env.put(Context.SECURITY_CREDENTIALS, credentials);   
  35.   
  36.     LogUtil.debug(_log, env);   
  37.   
  38.     LdapContext ctx = null;   
  39.   
  40.     try {   
  41.         ctx = new InitialLdapContext(env, null);   
  42.     }   
  43.     catch (Exception e) {   
  44.         if (_log.isWarnEnabled()) {   
  45.             _log.warn("Failed to bind to the LDAP server");   
  46.         }   
  47.   
  48.         if (_log.isDebugEnabled()) {   
  49.             _log.debug(e);   
  50.         }   
  51.     }   
  52.   
  53.     return ctx;   
  54. }  

 

6.测试用户:Authentication search Filter验证过滤语句,现在是过滤email,Test LDAP Users这个按钮是不会调用这个过滤的,Import Search Filter测试用户过滤语句。下面是liferay数据与ldap数据一对应的关系。

 测试成功

 

测试取用户列表代码代码 复制代码
  1. /**   
  2.  * 测试取用户列表   
  3.  * @param companyId   
  4.  * @param ctx   
  5.  * @param maxResults   
  6.  * @return   
  7.  * @throws Exception   
  8.  */   
  9. public static NamingEnumeration<SearchResult> getUsers(   
  10.         long companyId, LdapContext ctx, int maxResults)   
  11.     throws Exception {   
  12.   
  13.     String baseDN = PrefsPropsUtil.getString(   
  14.         companyId, PropsUtil.LDAP_BASE_DN);   
  15.     String userFilter = PrefsPropsUtil.getString(   
  16.         companyId, PropsUtil.LDAP_IMPORT_USER_SEARCH_FILTER);   
  17.   
  18.     return getUsers(companyId, ctx, maxResults, baseDN, userFilter);   
  19. }   
  20.   
  21. public static NamingEnumeration<SearchResult> getUsers(   
  22.         long companyId, LdapContext ctx, int maxResults, String baseDN,   
  23.         String userFilter)   
  24.     throws Exception {   
  25.   
  26.     SearchControls cons = new SearchControls(   
  27.         SearchControls.SUBTREE_SCOPE, maxResults, 0, null, false, false);   
  28.   
  29.     return ctx.search(baseDN, userFilter, cons);   
  30. }  

 

7.测试取得用户组织,基本上同上就不详解,仅贴出成功画面和相关代码

测试用户组织代码代码 复制代码
  1. /**   
  2.  * 测试用户组织   
  3.  * @param companyId   
  4.  * @param ctx   
  5.  * @param maxResults   
  6.  * @return   
  7.  * @throws Exception   
  8.  */   
  9. public static NamingEnumeration<SearchResult> getGroups(   
  10.         long companyId, LdapContext ctx, int maxResults)   
  11.     throws Exception {   
  12.   
  13.     String baseDN = PrefsPropsUtil.getString(   
  14.         companyId, PropsUtil.LDAP_BASE_DN);   
  15.     String groupFilter = PrefsPropsUtil.getString(   
  16.         companyId, PropsUtil.LDAP_IMPORT_GROUP_SEARCH_FILTER);   
  17.   
  18.     return getGroups(companyId, ctx, maxResults, baseDN, groupFilter);   
  19. }   
  20.   
  21. public static NamingEnumeration<SearchResult> getGroups(   
  22.         long companyId, LdapContext ctx, int maxResults, String baseDN,   
  23.         String groupFilter)   
  24.     throws Exception {   
  25.   
  26.     SearchControls cons = new SearchControls(   
  27.         SearchControls.SUBTREE_SCOPE, maxResults, 0, null, false, false);   
  28.   
  29.     return ctx.search(baseDN, groupFilter, cons);   
  30. }  
 

8.导入导出配置:Import Enabled:是否导入,导入时密码为空 Import on Startup Enabled:启动导入。Import Interval:导入间隔时间,注意时间太短会影响性能。Export Enabled:是否导出, 在用户登陆时和修改用户信息时都会导出至LDAP但不导出密码,在修改时如果修改了密码才会把密码也导出进去,如果密码未导入至LDAP并且前面的 Required也勾选了,那么LDAP验证不会通过 。后面三个为导出的设置。

 

导入用户代码 复制代码
  1. /**   
  2.  * 从LDAP中导入用户   
  3.  * @param companyId   
  4.  * @param ctx   
  5.  * @param attrs   
  6.  * @param password   
  7.  * @param importGroupMembership   
  8.  * @return   
  9.  * @throws Exception   
  10.  */   
  11. public static User importLDAPUser(   
  12.         long companyId, LdapContext ctx, Attributes attrs, String password,   
  13.         boolean importGroupMembership)   
  14.     throws Exception {   
  15.   
  16.     AttributesTransformer attrsTransformer =   
  17.         AttributesTransformerFactory.getInstance();   
  18.   
  19.     attrs = attrsTransformer.transformUser(attrs);   
  20.   
  21.     Properties userMappings = getUserMappings(companyId);   
  22.   
  23.     LogUtil.debug(_log, userMappings);   
  24.   
  25.     User defaultUser = UserLocalServiceUtil.getDefaultUser(companyId);   
  26.   
  27.     boolean autoPassword = false;   
  28.     boolean updatePassword = true;   
  29.   
  30.     if (password.equals(StringPool.BLANK)) {   
  31.         autoPassword = true;   
  32.         updatePassword = false;   
  33.     }   
  34.   
  35.     long creatorUserId = 0;   
  36.     boolean passwordReset = false;   
  37.     boolean autoScreenName = false;   
  38.     String screenName = LDAPUtil.getAttributeValue(   
  39.         attrs, userMappings.getProperty("screenName")).toLowerCase();   
  40.     String emailAddress = LDAPUtil.getAttributeValue(   
  41.         attrs, userMappings.getProperty("emailAddress"));   
  42.     Locale locale = defaultUser.getLocale();   
  43.     String firstName = LDAPUtil.getAttributeValue(   
  44.         attrs, userMappings.getProperty("firstName"));   
  45.     String middleName = LDAPUtil.getAttributeValue(   
  46.         attrs, userMappings.getProperty("middleName"));   
  47.     String lastName = LDAPUtil.getAttributeValue(   
  48.         attrs, userMappings.getProperty("lastName"));   
  49.   
  50.     if (Validator.isNull(firstName) || Validator.isNull(lastName)) {   
  51.         String fullName = LDAPUtil.getAttributeValue(   
  52.             attrs, userMappings.getProperty("fullName"));   
  53.   
  54.         String[] names = LDAPUtil.splitFullName(fullName);   
  55.   
  56.         firstName = names[0];   
  57.         middleName = names[1];   
  58.         lastName = names[2];   
  59.     }   
  60.   
  61.     int prefixId = 0;   
  62.     int suffixId = 0;   
  63.     boolean male = true;   
  64.     int birthdayMonth = Calendar.JANUARY;   
  65.     int birthdayDay = 1;   
  66.     int birthdayYear = 1970;   
  67.     String jobTitle = LDAPUtil.getAttributeValue(   
  68.         attrs, userMappings.getProperty("jobTitle"));   
  69.     long[] organizationIds = new long[0];   
  70.     boolean sendEmail = false;   
  71.   
  72.     if (_log.isDebugEnabled()) {   
  73.         _log.debug(   
  74.             "Screen name " + screenName + " and email address " +   
  75.                 emailAddress);   
  76.     }   
  77.   
  78.     if (Validator.isNull(screenName) || Validator.isNull(emailAddress)) {   
  79.         if (_log.isWarnEnabled()) {   
  80.             _log.warn(   
  81.                 "Cannot add user because screen name and email address " +   
  82.                     "are required");   
  83.         }   
  84.   
  85.         return null;   
  86.     }   
  87.   
  88.     User user = null;   
  89.   
  90.     try {   
  91.   
  92.         // Find corresponding portal user   
  93.   
  94.         String authType = PrefsPropsUtil.getString(   
  95.             companyId, PropsUtil.COMPANY_SECURITY_AUTH_TYPE,   
  96.             PropsValues.COMPANY_SECURITY_AUTH_TYPE);   
  97.   
  98.         if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {   
  99.             user = UserLocalServiceUtil.getUserByScreenName(   
  100.                 companyId, screenName);   
  101.         }   
  102.         else {   
  103.             user = UserLocalServiceUtil.getUserByEmailAddress(   
  104.                 companyId, emailAddress);   
  105.         }   
  106.   
  107.         // Skip if is default user   
  108.   
  109.         if (user.isDefaultUser()) {   
  110.             return user;   
  111.         }   
  112.   
  113.         // Skip import if user fields has been already synced and if   
  114.         // import is part of a scheduled import   
  115.   
  116.         Date ldapUserModifiedDate = null;   
  117.   
  118.         String modifiedDate = LDAPUtil.getAttributeValue(   
  119.             attrs, "modifyTimestamp");   
  120.   
  121.         try {   
  122.             DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");   
  123.   
  124.             ldapUserModifiedDate = dateFormat.parse(modifiedDate);   
  125.   
  126.             if (ldapUserModifiedDate.equals(user.getModifiedDate()) &&   
  127.                 autoPassword) {   
  128.   
  129.                 if (_log.isDebugEnabled()) {   
  130.                     _log.debug(   
  131.                         "User is already syncronized, skipping user " +   
  132.                             user.getEmailAddress());   
  133.                 }   
  134.   
  135.                 return user;   
  136.             }   
  137.         }   
  138.         catch (ParseException pe) {   
  139.             if (_log.isDebugEnabled()) {   
  140.                 _log.debug(   
  141.                     "Unable to parse LDAP modify timestamp " +   
  142.                         modifiedDate);   
  143.             }   
  144.   
  145.             _log.debug(pe, pe);   
  146.         }   
  147.   
  148.         Contact contact = user.getContact();   
  149.   
  150.         Calendar birthdayCal = CalendarFactoryUtil.getCalendar();   
  151.   
  152.         birthdayCal.setTime(contact.getBirthday());   
  153.   
  154.         birthdayMonth = birthdayCal.get(Calendar.MONTH);   
  155.         birthdayDay = birthdayCal.get(Calendar.DATE);   
  156.         birthdayYear = birthdayCal.get(Calendar.YEAR);   
  157.   
  158.         // User exists so update user information   
  159.   
  160.         if (updatePassword) {   
  161.             user = UserLocalServiceUtil.updatePassword(   
  162.                 user.getUserId(), password, password, passwordReset,   
  163.                 true);   
  164.         }   
  165.   
  166.         user = UserLocalServiceUtil.updateUser(   
  167.             user.getUserId(), password, user.isPasswordReset(), screenName,   
  168.             emailAddress, user.getLanguageId(), user.getTimeZoneId(),   
  169.             user.getGreeting(), user.getComments(), firstName, middleName,   
  170.             lastName, contact.getPrefixId(), contact.getSuffixId(),   
  171.             contact.getMale(), birthdayMonth, birthdayDay, birthdayYear,   
  172.             contact.getSmsSn(), contact.getAimSn(), contact.getIcqSn(),   
  173.             contact.getJabberSn(), contact.getMsnSn(), contact.getSkypeSn(),   
  174.             contact.getYmSn(), jobTitle, user.getOrganizationIds());   
  175.   
  176.         if (ldapUserModifiedDate != null) {   
  177.             UserLocalServiceUtil.updateModifiedDate(   
  178.                 user.getUserId(), ldapUserModifiedDate);   
  179.         }   
  180.     }   
  181.     catch (NoSuchUserException nsue) {   
  182.   
  183.         // User does not exist so create   
  184.   
  185.     }   
  186.   
  187.     if (user == null) {   
  188.         try {   
  189.             if (_log.isDebugEnabled()) {   
  190.                 _log.debug("Adding user to portal " + emailAddress);   
  191.             }   
  192.   
  193.             user = UserLocalServiceUtil.addUser(   
  194.                 creatorUserId, companyId, autoPassword, password, password,   
  195.                 autoScreenName, screenName, emailAddress, locale, firstName,   
  196.                 middleName, lastName, prefixId, suffixId, male,   
  197.                 birthdayMonth, birthdayDay, birthdayYear, jobTitle,   
  198.                 organizationIds, sendEmail);   
  199.         }   
  200.         catch (Exception e){   
  201.             _log.error(   
  202.                 "Problem adding user with screen name " + screenName +   
  203.                     " and email address " + emailAddress,   
  204.                 e);   
  205.         }   
  206.     }   
  207.   
  208.     // Import user groups and membership   
  209.   
  210.     if (importGroupMembership && (user != null)) {   
  211.         String userMappingsGroup = userMappings.getProperty("group");   
  212.   
  213.         if (userMappingsGroup != null) {   
  214.             Attribute attr = attrs.get(userMappingsGroup);   
  215.   
  216.             if (attr != null){   
  217.                 _importGroupsAndMembershipFromLDAPUser(   
  218.                     companyId, ctx, user.getUserId(), attr);   
  219.             }   
  220.         }   
  221.     }   
  222.   
  223.     return user;   
  224. }  
 
导出用户代码代码 复制代码
  1. /**   
  2.      * 将用户导出至LDAP   
  3.      * @param user   
  4.      * @throws Exception   
  5.      */   
  6.     public static void exportToLDAP(User user) throws Exception {   
  7.         long companyId = user.getCompanyId();   
  8.   
  9.         if (!isAuthEnabled(companyId) || !isExportEnabled(companyId)) {   
  10.             return;   
  11.         }   
  12.   
  13.         LdapContext ctx = getContext(companyId);   
  14.   
  15.         if (ctx == null) {   
  16.             return;   
  17.         }   
  18.   
  19.         Properties userMappings = getUserMappings(companyId);   
  20.         Binding binding = getUser(user.getCompanyId(), user.getScreenName());   
  21.         String name = StringPool.BLANK;   
  22.   
  23.         if (binding == null) {   
  24.   
  25.             // Generate full DN based on user DN   
  26.   
  27.             StringMaker sm = new StringMaker();   
  28.   
  29.             sm.append(userMappings.getProperty("screenName"));   
  30.             sm.append(StringPool.EQUAL);   
  31.             sm.append(user.getScreenName());   
  32.             sm.append(StringPool.COMMA);   
  33.             sm.append(getUsersDN(companyId));   
  34.   
  35.             name = sm.toString();   
  36.   
  37.             // Create new user in LDAP   
  38.   
  39.             LDAPUser ldapUser = (LDAPUser)Class.forName(   
  40.                 PropsValues.LDAP_USER_IMPL).newInstance();   
  41.   
  42.             ldapUser.setUser(user);   
  43.   
  44.             ctx.bind(name, ldapUser);   
  45.         }   
  46.         else {   
  47.   
  48.             // Modify existing LDAP user record   
  49.   
  50.             name = getNameInNamespace(companyId, binding);   
  51.   
  52.             Modifications mods = Modifications.getInstance();   
  53.   
  54.             if (user.isPasswordModified() &&   
  55.                 Validator.isNotNull(user.getPasswordUnencrypted())) {   
  56.   
  57.                 mods.addItem(   
  58.                     userMappings.getProperty("password"),   
  59.                     user.getPasswordUnencrypted());   
  60.             }   
  61.   
  62.             mods.addItem(   
  63.                 userMappings.getProperty("emailAddress"),   
  64.                 user.getEmailAddress());   
  65.   
  66.             ModificationItem[] modItems = mods.getItems();   
  67.   
  68.             ctx.modifyAttributes(name, modItems);   
  69.         }   
  70.   
  71.         ctx.close();   
  72.     }  

 

9.Use LDAP Password Policy:是使用LDAP的密码策略,这个主要用在验证方面,不推荐使用。


  • Fc48286e-f827-3aa9-8fed-eba983fd8067-thumb
  • 大小: 4.1 KB
  • B36edc26-b54a-33cf-938b-5e470c1708ee-thumb
  • 大小: 2.3 KB
  • 590a6b93-2134-3280-aef6-1167cca52760-thumb
  • 大小: 5.4 KB
  • D5d072e3-eb0f-3410-b170-63599f3153ee-thumb
  • 大小: 2.1 KB
  • 240f10ec-01cd-39a1-bfbc-afad03da2eb6-thumb
  • 大小: 8.1 KB
  • 8ea694db-6ed5-3d86-aa0a-67ee5b0f0eca-thumb
  • 大小: 2.9 KB
  • 580f31c9-0648-3563-8026-d6e816d9444f-thumb
  • 大小: 2.4 KB
  • 27512da4-8e9c-3705-ac17-3409043e6246-thumb
  • 大小: 2.2 KB
  • D816c5f9-f84d-3192-bfb4-671939f245c5-thumb
  • 大小: 5.8 KB
评论
chirking 2008-12-09   回复
请问一下官方插件(如wiki)是怎么在liferay数据库中建立和链接自己的表的?
源代码中连接数据库的部分在哪?
实在是没弄明白啊,网上根本找不到这方面的资料
你能写一篇这方面的帖子么,谢谢了
hawk315 2008-12-05   回复
搞定了,谢谢!
Tyler_Zhou 2008-12-05   回复
hawk315 写道

我用5.1.2的版本。
配制完成后,重起Tomcat的时候报异常了。不知道,你这边是否也有异常?

启动导入错误,我出现过,是因为我配置写错了。你查一下看,liferay的默认的base dn配置是有问题的,最起码我的ldap服务建好后和我的是不对的,你查一下看。liferay导入是没有问题的。
hawk315 2008-12-04   回复
我这边的截图如何发到这个上面?
hawk315 2008-12-04   回复
提示我在导入操作的importLDAPUser方法里的
birthdayCal.setTime(contact.getBirthday());
这句空指针了。将其改成
if( null==contact.getBirthday() ){
   birthdayCal.setTime(new Date());
}else{
   birthdayCal.setTime(contact.getBirthday());
}
后,这一块没有异常了。
但是又有后面其他语句的异常。
我感觉Liferay不会有这样的BUG,怀疑是自己LDAP数据问题,可是又不知道如何去调。
故来请教。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多