[FIXED HUDSON-1589] Applied a patch from thepner.

My apologies for the delay in handling this.
This change will be in 1.219.



git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9609 71c3de6d-444a-0410-be80-ed276b4c234a

Originally-Committed-As: 38953b88698e9ec784a399dbb7af9dd1eae0507e
This commit is contained in:
kohsuke 2008-05-23 15:18:57 +00:00
parent fb41282deb
commit a953d15b38
2 changed files with 19 additions and 5 deletions

View file

@ -227,11 +227,21 @@ public class LDAPSecurityRealm extends SecurityRealm {
return "LDAP";
}
public void doServerCheck(StaplerRequest req, StaplerResponse rsp, @QueryParameter("server") final String server) throws IOException, ServletException {
public void doServerCheck(StaplerRequest req, StaplerResponse rsp, @QueryParameter("server") final String server,
@QueryParameter("managerDN") final String managerDN,
@QueryParameter("managerPassword") final String managerPassword
) throws IOException, ServletException {
new FormFieldValidator(req,rsp,true) {
protected void check() throws IOException, ServletException {
try {
DirContext ctx = LdapCtxFactory.getLdapCtxInstance("ldap://"+server+'/', new Hashtable());
Hashtable<String,String> props = new Hashtable<String,String>();
if(managerDN!=null && managerDN.trim().length() > 0 && !"undefined".equals(managerDN)) {
props.put(Context.SECURITY_PRINCIPAL,managerDN);
}
if(managerPassword!=null && managerPassword.trim().length() > 0 && !"undefined".equals(managerPassword)) {
props.put(Context.SECURITY_PRINCIPAL,managerPassword);
}
DirContext ctx = LdapCtxFactory.getLdapCtxInstance("ldap://"+server+'/', props);
ctx.getAttributes("");
ok(); // connected
} catch (NamingException e) {

View file

@ -1,7 +1,7 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Server}" help="/help/security/ldap/server.html">
<f:textbox name="ldap.server" value="${instance.server}"
checkUrl="'${rootURL}/securityRealms/LDAPSecurityRealm/serverCheck?server='+escape(this.value)"/>
checkUrl="'${rootURL}/securityRealms/LDAPSecurityRealm/serverCheck?server='+escape(this.value)+'&amp;managerDN='+escape(this.form.elements['ldap.managerDN'].value)+'&amp;managerPassword='+escape(this.form.elements['ldap.managerPassword'].value)"/>
</f:entry>
<f:advanced>
<f:entry title="${%root DN}" help="/help/security/ldap/rootDN.html">
@ -14,10 +14,14 @@
<f:textbox name="ldap.userSearch" value="${instance.userSearch}" />
</f:entry>
<f:entry title="${%Manager DN}" help="/help/security/ldap/managerDN.html">
<f:textbox name="ldap.managerDN" value="${instance.managerDN}" />
<f:textbox name="ldap.managerDN" value="${instance.managerDN}"
checkUrl="'${rootURL}/securityRealms/LDAPSecurityRealm/serverCheck?server='+escape(this.form.elements['ldap.server'].value)+'&amp;managerDN='+escape(this.value)+'&amp;managerPassword='+escape(this.form.elements['ldap.managerPassword'].value)"
/>
</f:entry>
<f:entry title="${%Manager Password}" help="/help/security/ldap/managerPassword.html">
<f:password name="ldap.managerPassword" value="${instance.managerPassword}" />
<f:password name="ldap.managerPassword" value="${instance.managerPassword}"
checkUrl="'${rootURL}/securityRealms/LDAPSecurityRealm/serverCheck?server='+escape(this.form.elements['ldap.server'].value)+'&amp;managerDN='+escape(this.form.elements['ldap.managerDN'].value)+'&amp;managerPassword='+escape(this.value)"
/>
</f:entry>
</f:advanced>
</j:jelly>