diff options
author | Cyrill von Wattenwyl <cvw@adfinis.com> | 2014-09-02 11:20:52 +0200 |
---|---|---|
committer | Cyrill von Wattenwyl <cvw@adfinis.com> | 2014-09-02 11:20:52 +0200 |
commit | 11a40dd1fef6c5b78b054617caba4325f95ee386 (patch) | |
tree | de2e1d7efd6423ef4d1256dd5c90a972ad172719 /plugins/password/drivers | |
parent | 187fd666aa2f32dedfe544d69b7cb213698197f2 (diff) | |
parent | ba084313bfc9c7a5a83e0611fe4376543cc1653d (diff) |
Merge branch 'master' of https://github.com/roundcube/roundcubemail
Conflicts:
plugins/password/config.inc.php.dist
Diffstat (limited to 'plugins/password/drivers')
-rw-r--r-- | plugins/password/drivers/gearman.php | 55 | ||||
-rw-r--r-- | plugins/password/drivers/ldap.php | 11 | ||||
-rw-r--r-- | plugins/password/drivers/ldap_simple.php | 15 | ||||
-rw-r--r-- | plugins/password/drivers/vpopmaild.php | 2 |
4 files changed, 73 insertions, 10 deletions
diff --git a/plugins/password/drivers/gearman.php b/plugins/password/drivers/gearman.php new file mode 100644 index 000000000..36571a98f --- /dev/null +++ b/plugins/password/drivers/gearman.php @@ -0,0 +1,55 @@ +<?php + +/** + * Gearman Password Driver + * + * Payload is json string containing username, oldPassword and newPassword + * Return value is a json string saying result: true if success. + * + * @version 1.0 + * @author Mohammad Anwari <mdamt@mdamt.net> + */ + +class rcube_gearman_password +{ + function save($currpass, $newpass) + { + if (extension_loaded('gearman')) { + $rcmail = rcmail::get_instance(); + $user = $_SESSION['username']; + $payload = array( + 'username' => $user, + 'oldPassword' => $currpass, + 'newPassword' => $newpass, + ); + + $gmc = new GearmanClient(); + $gmc->addServer($rcmail->config->get('password_gearman_host')); + + $result = $gmc->doNormal('setPassword', json_encode($payload)); + $success = json_decode($result); + + if ($success && $success->result == 1) { + return PASSWORD_SUCCESS; + } + else { + rcube::raise_error(array( + 'code' => 600, + 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Gearman authentication failed for user $user: $error" + ), true, false); + } + } + else { + rcube::raise_error(array( + 'code' => 600, + 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: PECL Gearman module not loaded" + ), true, false); + } + + return PASSWORD_ERROR; + } +} diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index 739958ad7..cc62595b5 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -130,9 +130,10 @@ class rcube_ldap_password */ function search_userdn($rcmail) { + $binddn = $rcmail->config->get('password_ldap_searchDN'); + $bindpw = $rcmail->config->get('password_ldap_searchPW'); + $ldapConfig = array ( - 'binddn' => $rcmail->config->get('password_ldap_searchDN'), - 'bindpw' => $rcmail->config->get('password_ldap_searchPW'), 'basedn' => $rcmail->config->get('password_ldap_basedn'), 'host' => $rcmail->config->get('password_ldap_host'), 'port' => $rcmail->config->get('password_ldap_port'), @@ -140,6 +141,12 @@ class rcube_ldap_password 'version' => $rcmail->config->get('password_ldap_version'), ); + // allow anonymous searches + if (!empty($binddn)) { + $ldapConfig['binddn'] = $binddn; + $ldapConfig['bindpw'] = $bindpw; + } + $ldap = Net_LDAP2::connect($ldapConfig); if (PEAR::isError($ldap)) { diff --git a/plugins/password/drivers/ldap_simple.php b/plugins/password/drivers/ldap_simple.php index 3e167ea5b..3c19ccde5 100644 --- a/plugins/password/drivers/ldap_simple.php +++ b/plugins/password/drivers/ldap_simple.php @@ -168,14 +168,16 @@ class rcube_ldap_simple_password */ function search_userdn($rcmail, $ds) { - $search_user = $rcmail->config->get('password_ldap_searchDN'); - $search_pass = $rcmail->config->get('password_ldap_searchPW'); + $search_user = $rcmail->config->get('password_ldap_searchDN'); + $search_pass = $rcmail->config->get('password_ldap_searchPW'); + $search_base = $rcmail->config->get('password_ldap_search_base'); + $search_filter = $rcmail->config->get('password_ldap_search_filter'); - if (empty($search_user)) { - return null; + if (empty($search_filter)) { + return false; } - $this->_debug("C: Bind $search_user, pass: **** [" . strlen($search_pass) . "]"); + $this->_debug("C: Bind " . ($search_user ? $search_user : '[anonymous]')); // Bind if (!ldap_bind($ds, $search_user, $search_pass)) { @@ -185,9 +187,6 @@ class rcube_ldap_simple_password $this->_debug("S: OK"); - $search_base = $rcmail->config->get('password_ldap_search_base'); - $search_filter = $rcmail->config->get('password_ldap_search_filter'); - $search_base = rcube_ldap_password::substitute_vars($search_base); $search_filter = rcube_ldap_password::substitute_vars($search_filter); diff --git a/plugins/password/drivers/vpopmaild.php b/plugins/password/drivers/vpopmaild.php index 6c1a9ee9d..40731206a 100644 --- a/plugins/password/drivers/vpopmaild.php +++ b/plugins/password/drivers/vpopmaild.php @@ -22,6 +22,8 @@ class rcube_vpopmaild_password $rcmail->config->get('password_vpopmaild_port'), null))) { return PASSWORD_CONNECT_ERROR; } + + $vpopmaild->setTimeout($rcmail->config->get('password_vpopmaild_timeout'),0); $result = $vpopmaild->readLine(); if(!preg_match('/^\+OK/', $result)) { |