1

我想知道是否有 api 可以查明 Liferay 系统是否配置了 ldap。liferay 是否有任何 api 可以给我这些信息?

任何帮助表示赞赏

谢谢洛克什

4

1 回答 1

0

这是一个双头刀片。

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 条件一起使用才能获得明确的解决方案。

于 2013-12-12T13:24:53.860 回答