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:
Dan Scott
2016-07-29 15:47:16 -04:00
parent 32806248e6
commit 063085741b

View File

@@ -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
@@ -492,6 +489,11 @@ public class LDAPAuthentication
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));