From 09cb6088595918b87753ca4281180e99dc106baa Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Thu, 12 Nov 2015 21:37:55 -0500 Subject: [PATCH] NIFI-655: - Adding support for specifying the user search base and user search filter in the active directory provider. --- .../nifi/ldap/ActiveDirectoryProvider.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/src/main/java/org/apache/nifi/ldap/ActiveDirectoryProvider.java b/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/src/main/java/org/apache/nifi/ldap/ActiveDirectoryProvider.java index 7be8ec9673..8397f16713 100644 --- a/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/src/main/java/org/apache/nifi/ldap/ActiveDirectoryProvider.java +++ b/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/src/main/java/org/apache/nifi/ldap/ActiveDirectoryProvider.java @@ -29,18 +29,23 @@ public class ActiveDirectoryProvider extends AbstractLdapProvider { @Override protected AbstractLdapAuthenticationProvider getLdapAuthenticationProvider(LoginIdentityProviderConfigurationContext configurationContext) throws ProviderCreationException { - final String domain = configurationContext.getProperty("Domain"); - if (StringUtils.isBlank(domain)) { - throw new ProviderCreationException("The Active Directory Domain must be specified."); - } final String url = configurationContext.getProperty("Url"); if (StringUtils.isBlank(url)) { - throw new ProviderCreationException("The Active Directory Url must be specified."); + throw new ProviderCreationException("The Active Directory 'Url' must be specified."); } - final String rootDn = configurationContext.getProperty("Root DN"); - - return new ActiveDirectoryLdapAuthenticationProvider(domain, url, StringUtils.isBlank(rootDn) ? null : rootDn); + final String domain = configurationContext.getProperty("Domain"); + final String userSearchBase = configurationContext.getProperty("User Search Base"); + + final ActiveDirectoryLdapAuthenticationProvider activeDirectoryAuthenticationProvider = + new ActiveDirectoryLdapAuthenticationProvider(StringUtils.isBlank(domain) ? null : domain, url, StringUtils.isBlank(userSearchBase) ? null : userSearchBase); + + final String userSearchFilter = configurationContext.getProperty("User Search Filter"); + if (StringUtils.isNotBlank(userSearchFilter)) { + activeDirectoryAuthenticationProvider.setSearchFilter(userSearchFilter); + } + + return activeDirectoryAuthenticationProvider; } }