mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +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_AUTHENTICATION, "simple");
|
||||||
env.put(javax.naming.Context.SECURITY_PRINCIPAL, adminUser);
|
env.put(javax.naming.Context.SECURITY_PRINCIPAL, adminUser);
|
||||||
env.put(javax.naming.Context.SECURITY_CREDENTIALS, adminPassword);
|
env.put(javax.naming.Context.SECURITY_CREDENTIALS, adminPassword);
|
||||||
|
|
||||||
// Create initial context
|
|
||||||
ctx = new InitialLdapContext(env, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -492,6 +489,11 @@ public class LDAPAuthentication
|
|||||||
env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "none");
|
env.put(javax.naming.Context.SECURITY_AUTHENTICATION, "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx == null) {
|
||||||
|
// Create initial context
|
||||||
|
ctx = new InitialLdapContext(env, null);
|
||||||
|
}
|
||||||
|
|
||||||
Attributes matchAttrs = new BasicAttributes(true);
|
Attributes matchAttrs = new BasicAttributes(true);
|
||||||
matchAttrs.put(new BasicAttribute(ldap_id_field, netid));
|
matchAttrs.put(new BasicAttribute(ldap_id_field, netid));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user