Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2 from stepanv/ldap_props

[JENKINS-12373] JNDI LDAP properties affected by System properties.
  • Loading branch information...
commit 57b9ede241e533ce544dd0686ca1a242109a606b 2 parents 99df18d + 8399970
@kohsuke kohsuke authored
View
16 src/main/java/hudson/plugins/active_directory/ActiveDirectorySecurityRealm.java
@@ -367,6 +367,19 @@ public DirContext bind(String principalName, String password, List<SocketInfo> l
throw new BadCredentialsException("Either no such user '"+principalName+"' or incorrect password", error);
}
+ private void customizeLdapProperty(Hashtable<String, String> props, String propName) {
+ String prop = System.getProperty(propName, null);
+ if (prop != null) {
+ props.put(propName, prop);
+ }
+ }
+
+ /** Lookups for hardcoded LDAP properties if they are specified as System properties and uses them */
+ private void customizeLdapProperties(Hashtable<String, String> props) {
+ customizeLdapProperty(props, "com.sun.jndi.ldap.connect.timeout");
+ customizeLdapProperty(props, "com.sun.jndi.ldap.read.timeout");
+ }
+
private LdapContext bind(String principalName, String password, SocketInfo server, Hashtable<String, String> props) throws NamingException {
String ldapUrl = (FORCE_LDAPS?"ldaps://":"ldap://") + server + '/';
String oldName = Thread.currentThread().getName();
@@ -375,6 +388,9 @@ private LdapContext bind(String principalName, String password, SocketInfo serve
try {
props.put(Context.PROVIDER_URL, ldapUrl);
props.put("java.naming.ldap.version", "3");
+
+ customizeLdapProperties(props);
+
LdapContext context = (LdapContext)LdapCtxFactory.getLdapCtxInstance(ldapUrl, props);
if (!FORCE_LDAPS) {
Please sign in to comment.
Something went wrong with that request. Please try again.