Hi,

Thanks for this great software!

I use 389 Directory Server with non anonymous access. However, LAM 3.6
can not authenticate with login method LDAP Search. I see some ldap
plugins can do that, so I check the code that related to that. Here my
ugly hack to allow LAM 3.6 LDAP search method to authenticate with
non-anonymous LDAP server (I try with 389 Directory Server a.k.a Red
Hat Directory Server):

--- diff begin ---
diff --git a/lib/ldap.inc b/lib/ldap.inc
index b1fcad8..7c3d5e1 100644
--- a/lib/ldap.inc
+++ b/lib/ldap.inc
@@ -107,6 +107,9 @@ class Ldap{
                                        return ldap_errno($this->server);
                                }
                        }
+                       if (($bind = @ldap_bind($this->server, $user,
$passwd)) === false ) {
+                               $bind = @ldap_bind($this->server,
"uid=$user,".$this->conf->getLoginSearchSuffix(), $passwd);
+                       }
                        $bind = @ldap_bind($this->server, $user, $passwd);
                        if ($bind) {
                                $return = ldap_errno($this->server);
diff --git a/templates/login.php b/templates/login.php
index 4ab7f16..1182076 100644
--- a/templates/login.php
+++ b/templates/login.php
@@ -472,7 +472,7 @@ if(!empty($_POST['checklogin'])) {
                $searchSuccess = true;
                $searchError = '';
                $searchLDAP = new Ldap($_SESSION['config']);
-               $searchLDAPResult = $searchLDAP->connect('', '', true);
+               $searchLDAPResult = $searchLDAP->connect($username, $password);
                if (! ($searchLDAPResult == 0)) {
                        $searchSuccess = false;
                        $searchError = _('Cannot connect to specified
LDAP server. Please try again.') . ' ' .
@ldap_error($searchLDAP->server());
--- diff end ---

Note that, server need full DN as username for authenticate. Maybe
other server use other form.

-- 
Hansen <mht>
http://hansen.alfansa.org
Please avoid sending me proprietary format (.doc, .xls, etc.) attachments
See http://www.gnu.org/philosophy/no-word-attachments.html

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Lam-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lam-public

Reply via email to