[sork] patch for passwd: ldap binddn and bindpasswd

tim lynch timl+horde at thirdage.com
Wed Jun 30 14:11:53 PDT 2004


hi folks. here is a little patch to have the passwd module use a binddn 
and bindpassword when first looking up the dn for a user.

like others, there's no anon binding on ldap around here. to get the dn 
of the user that we are changing password for, we must first bind as 
someone who can lookup the user's dn. preferably this could just 
referrence $conf['prefs']['params']['rootdn'] from horde/config/horde.php.

i noticed this issue was approached with the userdn pref. if someone 
could show me how to make it go that way, i'd rather not use my hack.

---------8<---------
Only in passwd/config: backends.php
diff -ru passwd-2.2.1/config/backends.php.dist 
passwd/config/backends.php.dist
--- passwd-2.2.1/config/backends.php.dist	2003-02-05 07:48:13.000000000 
-0800
+++ passwd/config/backends.php.dist	2004-06-30 13:34:09.961587000 -0700
@@ -124,6 +124,8 @@
          'host' => 'localhost',
          'port' => 389,
          'basedn' => 'o=example.com',
+        'binddn' => 'cn=passwd,ou=horde,o=example.com',
+        'bindpasswd' => 'ldappasswd',
          'uid' => 'uid',
          'realm' => '', // this will be appended to the username when
                         // looking for the userdn.
Only in passwd/config: conf.php
diff -ru passwd-2.2.1/lib/Driver/ldap.php passwd/lib/Driver/ldap.php
--- passwd-2.2.1/lib/Driver/ldap.php	2003-02-15 12:16:29.000000000 -0800
+++ passwd/lib/Driver/ldap.php	2004-06-30 14:03:52.679849000 -0700
@@ -32,6 +32,8 @@
          $this->_params['encryption'] = array_key_exists('encryption', 
$params) ? $params['encryption'] : 'crypt';
          $this->_params['uid']        = array_key_exists('uid', 
$params)        ? $params['uid'] : 'uid';
          $this->_params['basedn']     = array_key_exists('basedn', 
$params)     ? $params['basedn'] : '';
+        $this->_params['binddn']     = array_key_exists('binddn', 
$params)     ? $params['binddn'] : '';
+        $this->_params['bindpasswd']     = 
array_key_exists('bindpasswd', $params)     ? $params['bindpasswd'] : '';
          $this->_params['realm']      = array_key_exists('realm', 
$params)      ? $params['realm'] : '';
          $this->_params['userdn']     = array_key_exists('userdn', 
$params)     ? $params['userdn'] : null;
      }
@@ -53,6 +55,8 @@

          if (!is_null($userdn)) {
              $result = @ldap_bind($this->_ds, $userdn, $password);
+        } elseif (!is_null($this->_params['binddn']) && 
!is_null($this->_params['bindpasswd']) ) {
+            $result = @ldap_bind($this->_ds, $this->_params['binddn'], 
$this->_params['bindpasswd']);
          } else {
              $result = @ldap_bind($this->_ds);
          }


More information about the sork mailing list