Allow anonymous LDAP searches

pull/198/head
Aleksander Machniak 11 years ago
parent 79b25df70e
commit 7706df99f0

@ -130,9 +130,10 @@ class rcube_ldap_password
*/ */
function search_userdn($rcmail) function search_userdn($rcmail)
{ {
$binddn = $rcmail->config->get('password_ldap_searchDN');
$bindpw = $rcmail->config->get('password_ldap_searchPW');
$ldapConfig = array ( $ldapConfig = array (
'binddn' => $rcmail->config->get('password_ldap_searchDN'),
'bindpw' => $rcmail->config->get('password_ldap_searchPW'),
'basedn' => $rcmail->config->get('password_ldap_basedn'), 'basedn' => $rcmail->config->get('password_ldap_basedn'),
'host' => $rcmail->config->get('password_ldap_host'), 'host' => $rcmail->config->get('password_ldap_host'),
'port' => $rcmail->config->get('password_ldap_port'), 'port' => $rcmail->config->get('password_ldap_port'),
@ -140,6 +141,12 @@ class rcube_ldap_password
'version' => $rcmail->config->get('password_ldap_version'), 'version' => $rcmail->config->get('password_ldap_version'),
); );
// allow anonymous searches
if (!empty($binddn)) {
$ldapConfig['binddn'] = $binddn;
$ldapConfig['bindpw'] = $bindpw;
}
$ldap = Net_LDAP2::connect($ldapConfig); $ldap = Net_LDAP2::connect($ldapConfig);
if (PEAR::isError($ldap)) { if (PEAR::isError($ldap)) {

@ -168,14 +168,16 @@ class rcube_ldap_simple_password
*/ */
function search_userdn($rcmail, $ds) function search_userdn($rcmail, $ds)
{ {
$search_user = $rcmail->config->get('password_ldap_searchDN'); $search_user = $rcmail->config->get('password_ldap_searchDN');
$search_pass = $rcmail->config->get('password_ldap_searchPW'); $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)) { if (empty($search_filter)) {
return null; return false;
} }
$this->_debug("C: Bind $search_user, pass: **** [" . strlen($search_pass) . "]"); $this->_debug("C: Bind " . ($search_user ? $search_user : '[anonymous]'));
// Bind // Bind
if (!ldap_bind($ds, $search_user, $search_pass)) { if (!ldap_bind($ds, $search_user, $search_pass)) {
@ -185,9 +187,6 @@ class rcube_ldap_simple_password
$this->_debug("S: OK"); $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_base = rcube_ldap_password::substitute_vars($search_base);
$search_filter = rcube_ldap_password::substitute_vars($search_filter); $search_filter = rcube_ldap_password::substitute_vars($search_filter);

Loading…
Cancel
Save