这是一个双头刀片。
1 .如果门户是通过 portal-ext.properties 中的配置使用 ldap 设置的,则使用
Boolean ldapAuthEnabled = Boolean.valueOf(PropsUtil.get("ldap.auth.enabled"));
如果 ext props 文件中的 ldap auth 属性设置为 true,则上述行返回 true。
2 。如果在 GUI(控制面板)中设置了门户 ldap 属性,那么您必须通过 Portal/Portlet Props 检索它。这可以通过以下任何方式完成:
com.liferay.portal.model.PortalPreferences portalPrefs = com.liferay.portal.service.persistence.PortalPreferencesUtil.fetchByO_O(ownerId, ownerType);
com.liferay.portal.model.PortalPreferences portalPrefs = com.liferay.portal.service.persistence.PortalPreferencesUtil.fetchByO_O(ownerId, ownerType, retrieveFromCache);
com.liferay.portal.model.PortalPreferences portalPrefs = com.liferay.portal.service.persistence.PortalPreferencesUtil.fetchByPrimaryKey(portalPreferencesId);
但 liferay 建议不要使用 PortalPreferencesUtil:
门户首选项服务的持久性实用程序。这个
实用程序包装 PortalPreferencesPersistenceImpl 并提供直接
访问数据库以进行 CRUD 操作。此实用程序应仅
由服务层使用,因为它必须在事务中运行。
永远不要在 JSP、控制器、模型或其他
前端类。
为了更清晰的思路,请尝试运行此查询并检查 PREFERENCES 列中的 XML 结果:
select * from PORTALPREFERENCES where lower(preferences) like '%ldap%';
您必须使用带有 OR 条件的这两种解决方案才能获得明确的解决方案。