Re: Passwd 4 hook problem

Ralf Lang <[email protected]> Sun, 20 Nov 2011 15:10:43 +0100
Newsgroups gmane.comp.horde.sork
Organization B1 Systems GmbH
Message-ID <[email protected]>
Am Samstag, 19. November 2011, 19:20:23 schrieb Kinglok, Fong:
> 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 (
> [email protected]) 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 th=
en
> 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 =3D>
> $config) {
> =

> Any comment?
> =

> Kinglok, Fong
> =

> */var/www/html/webmail/passwd/hook.php*
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D
> class Passwd_Hooks
> {
>     /**
>      * Username hook.
>      *
>      * @param string $userid  The username.
>      * @param TODO $driver    TODO
>      *
>      * @return string  TODO
>      */
>     public function username($userid, $driver)
>     {
> *        $userid =3D 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 =3D> $config=
) {
>                 if ($backend =3D=3D 'expect') {
> =

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

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

Youse the composite backend.

-- =

Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: [email protected]

B1 Systems GmbH
Osterfeldstra=DFe 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
-- =

Sork mailing list - Join the hunt: http://horde.org/bounties/#sork
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]