From 92d1e8e22643ff141b4c530d0100ad3a11676a86 Mon Sep 17 00:00:00 2001 From: "jocuri%softhome.net" <> Date: Sat, 4 Mar 2006 20:08:31 +0000 Subject: Patch for bug 216902: support LDAPS connections; patch by Christian Krause , r=vladd, a=justdave. --- Bugzilla/Auth/Verify/LDAP.pm | 25 ++++++++++++++++++++++--- template/en/default/admin/params/ldap.html.tmpl | 3 ++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Bugzilla/Auth/Verify/LDAP.pm b/Bugzilla/Auth/Verify/LDAP.pm index e8e744971..376fac71d 100644 --- a/Bugzilla/Auth/Verify/LDAP.pm +++ b/Bugzilla/Auth/Verify/LDAP.pm @@ -73,10 +73,29 @@ sub authenticate { } my $LDAPport = "389"; # default LDAP port - if($LDAPserver =~ /:/) { - ($LDAPserver, $LDAPport) = split(":",$LDAPserver); + my $LDAPprotocol = "ldap"; + + if ($LDAPserver =~ /(ldap|ldaps):\/\/(.*)/) { + # ldap(s)://server(:port) + $LDAPprotocol = $1; + my $serverpart = $2; + if ($serverpart =~ /:/) { + # ldap(s)://server:port + ($LDAPserver, $LDAPport) = split(":", $serverpart); + } else { + # ldap(s)://server + $LDAPserver = $serverpart; + if ($LDAPprotocol eq "ldaps") { + $LDAPport = "636"; + } + } + } elsif ($LDAPserver =~ /:/) { + # server:port + ($LDAPserver, $LDAPport) = split(":", $LDAPserver); } - my $LDAPconn = Net::LDAP->new($LDAPserver, port => $LDAPport, version => 3); + + + my $LDAPconn = Net::LDAP->new("$LDAPprotocol://$LDAPserver:$LDAPport", version => 3); if(!$LDAPconn) { return (AUTH_ERROR, undef, "connect_failed"); } diff --git a/template/en/default/admin/params/ldap.html.tmpl b/template/en/default/admin/params/ldap.html.tmpl index 6e7068796..af1a756a4 100644 --- a/template/en/default/admin/params/ldap.html.tmpl +++ b/template/en/default/admin/params/ldap.html.tmpl @@ -26,7 +26,8 @@ [% param_descs = { LDAPserver => "The name (and optionally port) of your LDAP server " _ - "(e.g. ldap.company.com, or ldap.company.com:portnum).", + "(e.g. ldap.company.com, or ldap.company.com:portnum). " _ + "Can be prefixed with ldap:// (default) or ldaps:// (for a secure connection).", LDAPbinddn => "If your LDAP server requires that you use a binddn and password " _ "instead of binding anonymously, enter it here " _ -- cgit v1.2.3-24-g4f1b