Liferay api查找系统是否配置为ldap或liferay数据库

时间:2013-06-18 08:42:36

标签: ldap liferay liferay-6 spring-ldap

我想知道是否有api可以找出Liferay系统是否配置了ldap。有什么api暴露在liferay中可以给我这个信息吗?

感谢任何帮助

感谢 LOKESH

1 个答案:

答案 0 :(得分: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条件的解决方案才能获得明确的解决方案。