From dbb4dc8e4e689253f0e9c5d162f342e8e652c456 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Tue, 11 Jul 2006 07:42:57 +0000 Subject: Bug 339731: [LDAP] URI-parsing code duplicated with Net::LDAP - Patch by guillomovitch@zarb.org r=mkanat a=justdave --- Bugzilla/Auth/Verify/LDAP.pm | 30 ++----------------------- docs/xml/installation.xml | 11 ++++++++- template/en/default/admin/params/ldap.html.tmpl | 5 ++++- 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Bugzilla/Auth/Verify/LDAP.pm b/Bugzilla/Auth/Verify/LDAP.pm index 9f050d854..343f7952c 100644 --- a/Bugzilla/Auth/Verify/LDAP.pm +++ b/Bugzilla/Auth/Verify/LDAP.pm @@ -40,9 +40,6 @@ use Bugzilla::Error; use Net::LDAP; -use constant DEFAULT_PORT => 389; -use constant DEFAULT_SSL_PORT => 636; - use constant admin_can_create_account => 0; use constant user_can_create_account => 0; @@ -140,31 +137,8 @@ sub ldap { my $server = Bugzilla->params->{"LDAPserver"}; ThrowCodeError("ldap_server_not_defined") unless $server; - my $port = DEFAULT_PORT; - my $protocol = "ldap"; - - if ($server =~ /(ldap|ldaps):\/\/(.*)/) { - # ldap(s)://server(:port) - $protocol = $1; - my $server_part = $2; - if ($server_part =~ /:/) { - # ldap(s)://server:port - ($server, $port) = split(":", $server_part); - } else { - # ldap(s)://server - $server = $server_part; - if ($protocol eq "ldaps") { - $port = DEFAULT_SSL_PORT; - } - } - } elsif ($server =~ /:/) { - # server:port - ($server, $port) = split(":", $server); - } - - my $conn_string = "$protocol://$server:$port"; - $self->{ldap} = new Net::LDAP($conn_string) - || ThrowCodeError("ldap_connect_failed", { server => $conn_string }); + $self->{ldap} = new Net::LDAP($server) + || ThrowCodeError("ldap_connect_failed", { server => $server }); # try to start TLS if needed if (Bugzilla->params->{"LDAPstarttls"}) { diff --git a/docs/xml/installation.xml b/docs/xml/installation.xml index 743d67735..ce760842e 100644 --- a/docs/xml/installation.xml +++ b/docs/xml/installation.xml @@ -1,5 +1,5 @@ - + Installing Bugzilla @@ -1379,6 +1379,15 @@ c:\perl\bin\perl.exe -xc:\bugzilla -wT "%s" %s Ex. ldap.company.com or ldap.company.com:3268 + You can also specify a LDAP URI, so as to use other + protocols, such as LDAPS or LDAPI. If port was not specified in + the URI, the default is either 389 or 636 for 'LDAP' and 'LDAPS' + schemes respectively. + + Ex. ldap://ldap.company.com, + ldaps://ldap.company.com or + ldapi://%2fvar%2flib%2fldap_sock + diff --git a/template/en/default/admin/params/ldap.html.tmpl b/template/en/default/admin/params/ldap.html.tmpl index aef2713b1..a3c7e4643 100644 --- a/template/en/default/admin/params/ldap.html.tmpl +++ b/template/en/default/admin/params/ldap.html.tmpl @@ -27,7 +27,10 @@ [% param_descs = { LDAPserver => "The name (and optionally port) of your LDAP server " _ "(e.g. ldap.company.com, or ldap.company.com:portnum). " _ - "Can be prefixed with ldap:// (default) or ldaps:// (for a secure connection).", + "URI syntax can also be used, such as "_ + "ldaps://ldap.company.com (for a secure connection) or " _ + "ldapi://%2fvar%2flib%2fldap_sock (for a socket-based " _ + "local connection.", LDAPstartls => "Whether to require encrypted communication once normal " _ "LDAP connection achieved with the server.", -- cgit v1.2.3-24-g4f1b