alecpl
2009-10-06 ffeab7fe7e0ccf1d458d6a863600359c38769950
plugins/password/drivers/ldap.php
@@ -21,6 +21,14 @@
    
    // Building user DN
    $userDN = str_replace('%login', $_SESSION['username'], $rcmail->config->get('password_ldap_userDN_mask'));
    $parts = explode('@', $_SESSION['username']);
    if (count($parts) == 2)
    {
        $userDN = str_replace('%name', $parts[0], $userDN);
        $userDN = str_replace('%domain', $parts[1], $userDN);
    }
    if (empty($userDN)) {return PASSWORD_CONNECT_ERROR;}
    
    // Connection Method
@@ -54,7 +62,7 @@
    // Writing new crypted password to LDAP
    $userEntry = $ldap->getEntry($userDN);
    if (Net_LDAP2::isError($userEntry)) {return PASSWORD_CONNECT_ERROR;}
    if (!$userEntry->replace(array($rcmail->config->get('password_ldap_pwattr') => $newCryptedPassword))) {return PASSWORD_CONNECT_ERROR;}
    if (!$userEntry->replace(array($rcmail->config->get('password_ldap_pwattr') => $newCryptedPassword),$rcmail->config->get('password_ldap_force_replace'))) {return PASSWORD_CONNECT_ERROR;}
    if (Net_LDAP2::isError($userEntry->update())) {return PASSWORD_CONNECT_ERROR;}
    
    // All done, no error