掲示板

Access LDAP server setting via the APIs?

thumbnail
8年前 に William Gosse によって更新されました。

Access LDAP server setting via the APIs?

Liferay Master 投稿: 533 参加年月日: 10/07/04 最新の投稿
I'm on Liferay 6.2. Is there a way to access an LDAP server setting that have been configured in the Control Panel via the Liferay APIs? If so an example would be great to see. Thanks.
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: Access LDAP server setting via the APIs?

Liferay Legend 投稿: 14915 参加年月日: 06/09/02 最新の投稿
They're stored as part a PortalPreference object. The path is kinda convoluted, but you can find some stuff in com.liferay.portlet.portalsettings.action.EditLDAPServerAction.
thumbnail
8年前 に William Gosse によって更新されました。

RE: Access LDAP server setting via the APIs? (回答)

Liferay Master 投稿: 533 参加年月日: 10/07/04 最新の投稿
I got this to work for me:
PortletPreferences prefs = PortalPreferencesLocalServiceUtil.getPreferences(user.getCompanyId(), 1);
String ldapId = prefs.getValue("ldap.server.ids", "XXX");
if (ldapId != null) {
	if (!ldapId.equals("XXX")) {
		ldapUrl = prefs.getValue("ldap.base.provider.url." + ldapId, "XXX");
		ldapBaseDn = prefs.getValue("ldap.base.dn." + ldapId, "XXX");
		ldapPrincipal = prefs.getValue("ldap.security.principal." + ldapId, "XXX");
		ldapCredentials = prefs.getValue("ldap.security.credentials." + ldapId, "XXX");					
	}
}