Documentation updates for Active Directory Realm. Also replaces empty string arrays with Strings.EMPTY_ARRAY
Original commit: elastic/x-pack-elasticsearch@3f02d89a20
This commit is contained in:
parent
350665bb26
commit
8397112422
|
@ -80,7 +80,7 @@ public class ActiveDirectoryConnectionFactory extends AbstractComponent implemen
|
||||||
DirContext ctx = new InitialDirContext(ldapEnv);
|
DirContext ctx = new InitialDirContext(ldapEnv);
|
||||||
SearchControls searchCtls = new SearchControls();
|
SearchControls searchCtls = new SearchControls();
|
||||||
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||||
searchCtls.setReturningAttributes( new String[] {} );
|
searchCtls.setReturningAttributes( Strings.EMPTY_ARRAY );
|
||||||
|
|
||||||
String searchFilter = "(&(objectClass=user)(userPrincipalName={0}))";
|
String searchFilter = "(&(objectClass=user)(userPrincipalName={0}))";
|
||||||
NamingEnumeration<SearchResult> results = ctx.search(userSearchDN, searchFilter, new Object[]{ userPrincipal }, searchCtls);
|
NamingEnumeration<SearchResult> results = ctx.search(userSearchDN, searchFilter, new Object[]{ userPrincipal }, searchCtls);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.shield.authc.ldap;
|
package org.elasticsearch.shield.authc.ldap;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||||
import org.elasticsearch.shield.authc.support.ldap.AbstractLdapConnection;
|
import org.elasticsearch.shield.authc.support.ldap.AbstractLdapConnection;
|
||||||
|
@ -67,7 +68,7 @@ public class LdapConnection extends AbstractLdapConnection {
|
||||||
public List<String> getGroupsFromSearch(String userDn){
|
public List<String> getGroupsFromSearch(String userDn){
|
||||||
List<String> groups = new LinkedList<>();
|
List<String> groups = new LinkedList<>();
|
||||||
SearchControls search = new SearchControls();
|
SearchControls search = new SearchControls();
|
||||||
search.setReturningAttributes( new String[0] );
|
search.setReturningAttributes( Strings.EMPTY_ARRAY );
|
||||||
search.setSearchScope( this.isGroupSubTreeSearch ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE);
|
search.setSearchScope( this.isGroupSubTreeSearch ? SearchControls.SUBTREE_SCOPE : SearchControls.ONELEVEL_SCOPE);
|
||||||
|
|
||||||
//This could be made could be made configurable but it should cover all cases
|
//This could be made could be made configurable but it should cover all cases
|
||||||
|
@ -77,7 +78,7 @@ public class LdapConnection extends AbstractLdapConnection {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NamingEnumeration<SearchResult> results = jndiContext.search(
|
NamingEnumeration<SearchResult> results = jndiContext.search(
|
||||||
groupSearchDN, filter, new Object[]{ userDn }, search);
|
groupSearchDN, filter, new Object[]{userDn}, search);
|
||||||
while (results.hasMoreElements()){
|
while (results.hasMoreElements()){
|
||||||
groups.add(results.next().getNameInNamespace());
|
groups.add(results.next().getNameInNamespace());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue