[sork] Passwd 4 hook problem

Kinglok, Fong busywater at gmail.com
Sat Nov 19 18:20:23 UTC 2011


I am using horde 4.0.11, IMP 5.0.14.  Horde authentication is done by SQL.
I also make use of horde username hook.  IMP login is done by configuring
the backends.php.

I would like to use Passwd to update both passwords of horde and email
backend (running vpopmail).  Therefore, horde (user) and vpopmail (
user at example.com) have to be updated in the same time.  It seems me that
hook of Passwd must be used.

My method is to strip the domain from $userid in function username and then
add the domain back if the backend is 'expect'.

However, the screen just turn white whenever I try to reset a user's
password.  After some investigation, I believe the problem is from the
statement:         foreach ($driver->_params['drivers'] as $backend =>
$config) {

Any comment?

Kinglok, Fong

*/var/www/html/webmail/passwd/hook.php*
=================================
class Passwd_Hooks
{
    /**
     * Username hook.
     *
     * @param string $userid  The username.
     * @param TODO $driver    TODO
     *
     * @return string  TODO
     */
    public function username($userid, $driver)
    {
*        $userid = substr($userid,0,strpos($userid,"@"));
*
        if ($driver instanceof Passwd_Driver_Expect) {
            return $userid . '@example.com';
        }

        if ($driver instanceof Passwd_Driver_Composite) {
            foreach ($driver->_params['drivers'] as $backend => $config) {
                if ($backend == 'expect') {

$driver->_params['drivers']['expect']['params']['be_username'] = $userid .
'@example.com';
                    break;
                }
            }
        }
        return $userid;
    }
}
=============================================

*/var/www/html/webmail/passwd/backends.php*
========================
<?php
$backends['composite'] = array(
        'name' => 'All Services',
        'preferred' => '',
        'password policy' => array(
                'minLength' => 3,
                'maxLength' => 20,
                //'minClasses' => 2,
        ),
        'driver' => 'composite',
        'params' => array(
                'drivers' => array(
                        'sql' => array(
                                'name' => 'Horde Authentication',
                                'driver' => 'Sql',
                                'required' => true,
                                'params' => array(
                                        'phptype'    => 'mysql',
                                        'hostspec'   => 'localhost',
                                        'username'   => 'hordeuser',
                                        'password'   => 'XXXXXXXXXXX',
                                        'encryption' => 'plain',
                                        'database'   => 'horde4',
                                        'table'      => 'horde_users',
                                        'user_col'   => 'user_uid',
                                        'pass_col'   => 'user_pass',
                                        'show_encryption' => false
                                        // 'query_lookup' => '',
                                        // 'query_modify' => '',
                                        ),
                                ),
                        'expect' => array(
                                'name' => 'Webmail Password',
                                'preferred' => '',
                                'driver' => 'expect',
                                'required' => true,
                                'params' => array(
                                        'program' => '/usr/bin/expect',
                                        'script' => dirname(__FILE__) .
'/../scripts/vpopmail_cdb_expect',
                                        'be_username' => '',
                                        ),
                                ),
                    }
              }
      }


More information about the sork mailing list