mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Initialize LDAP context object for anonymous searching
In commit 7cf90d3db2
we added support for StartTLS in LDAP, but
opened up a path for a NullPointerException when anonymous searching of
the LDAP directory is in use.
Signed-off-by: Dan Scott <dscott@laurentian.ca>
This commit is contained in:
@@ -481,9 +481,6 @@ public class LDAPAuthentication
|
||||
env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "simple");
|
||||
env.put(javax.naming.Context.SECURITY_PRINCIPAL, adminUser);
|
||||
env.put(javax.naming.Context.SECURITY_CREDENTIALS, adminPassword);
|
||||
|
||||
// Create initial context
|
||||
ctx = new InitialLdapContext(env, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -491,6 +488,11 @@ public class LDAPAuthentication
|
||||
// Use anonymous authentication
|
||||
env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "none");
|
||||
}
|
||||
|
||||
if (ctx == null) {
|
||||
// Create initial context
|
||||
ctx = new InitialLdapContext(env, null);
|
||||
}
|
||||
|
||||
Attributes matchAttrs = new BasicAttributes(true);
|
||||
matchAttrs.put(new BasicAttribute(ldap_id_field, netid));
|
||||
|
Reference in New Issue
Block a user