From 62da5f2cf569708e33c3236e294fe3e31b1438dc Mon Sep 17 00:00:00 2001 From: nbm Date: Mon, 11 Oct 2004 10:05:57 +0000 Subject: [PATCH] Add support for OpenLDAP2 servers that don't offer anonymous bind or LDAPv2 bings. --- lib/authentication/class.AuthLdap.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/authentication/class.AuthLdap.php b/lib/authentication/class.AuthLdap.php index ac7cd16..0405b65 100644 --- a/lib/authentication/class.AuthLdap.php +++ b/lib/authentication/class.AuthLdap.php @@ -32,6 +32,10 @@ * - Change documentation to phpdoc style (http://phpdocu.sourceforge.net) * - Added a constructor * - Added an attribute array parameter to the getUsers method + * 20040909, Daniel Patrick + * - Added server type OpenLDAP2 + * - Added support for OpenLDAP2 servers that deny Anonymous Bind + * - Added support for OpenLDAP2 servers that deny LDAPv2 protocol */ class AuthLdap { @@ -125,8 +129,14 @@ class AuthLdap { function connect() { foreach ($this->server as $key => $host) { $this->connection = ldap_connect( $host); + if ( $this->serverType == "OpenLDAP2" ) { + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + } if ( $this->connection) { - if ($this->serverType == "ActiveDirectory") { + if (($this->serverType == "ActiveDirectory") || + (($this->serverType == "OpenLDAP2") && + (!$this->searchUser == "") && + (!$this->searchPassword == ""))) { return true; } else { // Connected, now try binding anonymously @@ -423,7 +433,10 @@ class AuthLdap { // Perform the search and get the entry handles // if the directory is AD, then bind first with the search user first - if ($this->serverType == "ActiveDirectory") { + if (($this->serverType == "ActiveDirectory") || + (($this->serverType == "OpenLDAP2") && + (!$this->searchUser == "") && + (!$this->searchPassword == ""))) { $this->authBind($this->searchUser, $this->searchPassword); } $this->result = ldap_search( $this->connection, $checkDn, $this->getUserIdentifier() . "=$search"); -- libgit2 0.21.4