[horde] Account Password

Luiz Morte morte at chsti.com
Mon Dec 11 09:10:48 PST 2006


Jan Schneider escreveu:
> Zitat von Luiz Morte <morte at chsti.com>:
>
>>
>> Hello,
>>
>> I´ve seen in Horde->Options->Account Password, the user can recover the
>> password.
>> Where is the page from user to put the answer for the question?
>
> It's linked from the login page, if you use an authentication backend
> that supports resetting passwords.
>
> Jan.
Hello Jan, thanks for the answer.

I´m using with ldap, so it doesn't supports resetting passwords.

I've made a small solution for that. I hope this can help someone and if
you see a better solution, let me know.
(the solution is based in the "password packet")

In .../horde/lib/Horde/Auth/ldap.php, I created a function like this:

    function resetPassword($user_id)
    {
        list($base) = split("horde", dirname(__FILE__));
        $base = sprintf("%s/horde/passwd", $base);

        @define('PASSWD_BASE', $base);
        require PASSWD_BASE . '/config/backends.php';

        // Get the backend details.
        $backend_key = 'ldapadmin';
        $driver = $backends[$backend_key]['driver'];
        $params = $backends[$backend_key]['params'];

        // Create a Password_Driver instance.
        require_once PASSWD_BASE . '/lib/Driver.php';
        $daemon = &Passwd_Driver::factory($driver, $params);

        if (is_a($daemon, 'PEAR_Error')) {
            $notification->push(_("Password module is not properly
configured"),
                                'horde.error');
            break;
        }

        // Create DN
        list($user, $domain) = split("@", $user_id);
        $userdn = XXXXX
        $admindn = sprintf("%s", $params['admindn']);

        /* Get a new random password. */
        $new_password = Auth::genRandomPassword();
        $new_details[$params['attribute']] =
$daemon->encryptPassword($new_password);

        // Connect as the user.
        $result = $this->_connect($admindn, $params['adminpw'],
                                  !empty($this->_params['sslhost']));
        if (is_a($result, 'PEAR_Error')) {
            if ($result->getMessage() == _("Could not bind to ldap
server")) {
                return PEAR::raiseError(_("Incorrect Password"));
            }
            return $result;
        }

        if (!ldap_mod_replace($this->_ds, $userdn, $new_details)) {
                exit;
            return PEAR::raiseError(ldap_error($this->_ds));
        }
        return $new_password;
    }

The function needs:
1. The "password packet" installed;
2. XXX: put your DN
3. To change , in ldap.php, the "resetpassoword to true.
    var $capabilities = array('add'           => true,
                              'update'        => true,
                              'resetpassword' => true,
                              'remove'        => true,
                              'list'          => true,
                              'transparent'   => false);


With this changes, It´s work for me.

Don´t forget to test, before put this to work :))

Thanks,
Luiz Morte.


More information about the horde mailing list