diff --git a/src/main/java/org/elasticsearch/shield/authc/active_directory/ActiveDirectoryConnectionFactory.java b/src/main/java/org/elasticsearch/shield/authc/active_directory/ActiveDirectoryConnectionFactory.java index 7e552149301..df080c31aeb 100644 --- a/src/main/java/org/elasticsearch/shield/authc/active_directory/ActiveDirectoryConnectionFactory.java +++ b/src/main/java/org/elasticsearch/shield/authc/active_directory/ActiveDirectoryConnectionFactory.java @@ -80,7 +80,7 @@ public class ActiveDirectoryConnectionFactory extends AbstractComponent implemen DirContext ctx = new InitialDirContext(ldapEnv); SearchControls searchCtls = new SearchControls(); searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); - searchCtls.setReturningAttributes( new String[] {} ); + searchCtls.setReturningAttributes( Strings.EMPTY_ARRAY ); String searchFilter = "(&(objectClass=user)(userPrincipalName={0}))"; NamingEnumeration results = ctx.search(userSearchDN, searchFilter, new Object[]{ userPrincipal }, searchCtls); diff --git a/src/main/java/org/elasticsearch/shield/authc/ldap/LdapConnection.java b/src/main/java/org/elasticsearch/shield/authc/ldap/LdapConnection.java index bf733e63f28..3ddd3470ed2 100644 --- a/src/main/java/org/elasticsearch/shield/authc/ldap/LdapConnection.java +++ b/src/main/java/org/elasticsearch/shield/authc/ldap/LdapConnection.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.shield.authc.ldap; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.shield.authc.support.ldap.AbstractLdapConnection; @@ -67,7 +68,7 @@ public class LdapConnection extends AbstractLdapConnection { public List getGroupsFromSearch(String userDn){ List groups = new LinkedList<>(); SearchControls search = new SearchControls(); - search.setReturningAttributes( new String[0] ); + search.setReturningAttributes( Strings.EMPTY_ARRAY ); search.setSearchScope( this.isGroupSubTreeSearch ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE); //This could be made could be made configurable but it should cover all cases @@ -77,7 +78,7 @@ public class LdapConnection extends AbstractLdapConnection { try { NamingEnumeration results = jndiContext.search( - groupSearchDN, filter, new Object[]{ userDn }, search); + groupSearchDN, filter, new Object[]{userDn}, search); while (results.hasMoreElements()){ groups.add(results.next().getNameInNamespace()); }