[sork] Head version of passwd w/ldap

Edwin Culp eculp@encontacto.net
Wed, 17 Jul 2002 12:48:44 -0700


Everything was working but now with cvs head and the config changes
I'm seeing the following with the passwd module and ldap:

  I get an error message from main.php
    Password module is not properly configured

I have found:

    function Passwd_Driver_ldapd($params = array())

That seems to be built from the driver variable that is ldap. Either we
should change ldap in conf.php to ldapd or this to ldap.

In the new config file rootdn is in the conf.php.dist and it seems that 
basedn is being used in lib/Driver/ldap.php although in my tests I added
rootdn for ldap_connect to lib/Driver/ldap.php.

I also removed the old PASSWD_BASE . ldap.php just in case it was causing
the problem.  I think the other drivers could/should be removed from 
PASSWD_BASE.

I'm going to add the cvs diff to this with the observation that I was not
sure where hordeuser and password should be defined.  I chose conf.php over
lib/Driver/ldap.php

The following diff on lib/Driver/ldap.php works for me.

Index: ldap.php
===================================================================
RCS file: /repository/passwd/lib/Driver/ldap.php,v
retrieving revision 1.1
diff -u -b -r1.1 ldap.php
--- ldap.php        16 Jul 2002 23:00:46 -0000        1.1
+++ ldap.php        17 Jul 2002 19:33:35 -0000
@@ -10,7 +10,7 @@
  * @package  passwd
  */
 
-    class Passwd_Driver_ldapd extends Passwd_Driver {
+    class Passwd_Driver_ldap extends Passwd_Driver {
 
     /** file pointer to the ldap connection. */
     var $ds;
@@ -21,11 +21,11 @@
     var $params;
 
     /**
-     * Constructs a new ldapd Passwd_Driver object.
+     * Constructs a new ldap Passwd_Driver object.
      *
      * @param array  $params    A hash containing connection parameters.
      */
-    function Passwd_Driver_ldapd($params = array())
+    function Passwd_Driver_ldap($params = array())
     {
         $this->params = $params;
     }
@@ -36,18 +36,20 @@
      *
      * @param    $host     The ldap server hostname.
      * @param    $port     The ldap server port number to connect to.
+     * @param    $rootdn        User DN.
+     * @param    $ldappassword  User password.
      *
      * @return   boolean   True or False based on success of connect and bind.
      *
      */
 
-    function connect($host, $port) {
+    function connect($host, $port, $rootdn, $ldappassword ) {
         $this->ds = ldap_connect($host, $port);
         if (!$this->ds) {
            $this->err_str = _("Could not connect to ldap server");
            return false;
         }
-        if (!ldap_bind($this->ds)) {
+        if (!ldap_bind($this->ds, $rootdn, $ldappassword)) {
           $this->err_str = _("Could not bind to ldap server as guest");
           return false;
         }        
@@ -147,6 +149,8 @@
         $host       = @$this->params['default']['host'];
         $port       = @$this->params['default']['port'];
         $basedn     = @$this->params['default']['basedn'];
+        $rootdn     = @$this->params['default']['rootdn'];
+        $ldappassword     = @$this->params['default']['ldappassword'];
         $uid        = @$this->params['default']['uid'];
         $encryption = @$this->params['default']['encryption'];
 
@@ -165,7 +169,7 @@
         }
 
         $return_value = false;
-        if ($this->connect($host, $port)) {
+        if ($this->connect($host, $port, $rootdn, $ldappassword)) {
             if ($this->modify($username, $realm, $oldpassword,
                               $newpassword, $basedn, $uid, $encryption)) {
                         $return_value = true;


Next is a diff for conf.php.dist that shows rootdn and the username and 
ldappassword.

Index: conf.php.dist
===================================================================
RCS file: /repository/passwd/config/conf.php.dist,v
retrieving revision 1.8
diff -u -r1.8 conf.php.dist
--- conf.php.dist        16 Jul 2002 23:00:38 -0000        1.8
+++ conf.php.dist        17 Jul 2002 19:22:56 -0000
@@ -63,14 +63,19 @@
 
 // This is an example for a ldap server (uncomment and modify as needed)
 // Encryption can be on of the folowing: plain, SHA or crypt
+//
+// $usermail=Auth::getAuth();
+// $password=Auth::getCredential('password');
+//
 // $conf['server']['params']['default'] = array(
 //   'host' => 'localhost',
 //   'port' => 389,
 //   'rootdn' => 'cn=root,o=example.com',
+//   'rootdn' => 'mail=' . $usermail . ',o=example.com',
+//   'basedn' => 'o=example.com',
 //   'uid' => 'mail',
 //   'encryption' => 'crypt'
 // );
-
 
 // Define apps to put in the menu bar.  To include IMP in the menu bar, you
 // would add: $conf['menu']['apps'] = array('imp');

I hope this helps,

ed