|
|
@ -4,7 +4,7 @@
|
|
|
|
| program/include/rcube_ldap.php |
|
|
|
|
| program/include/rcube_ldap.php |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| This file is part of the Roundcube Webmail client |
|
|
|
|
| This file is part of the Roundcube Webmail client |
|
|
|
|
| Copyright (C) 2006-2009, Roundcube Dev. - Switzerland |
|
|
|
|
| Copyright (C) 2006-2010, Roundcube Dev. - Switzerland |
|
|
|
|
| Licensed under the GNU GPL |
|
|
|
|
| Licensed under the GNU GPL |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| PURPOSE: |
|
|
|
|
| PURPOSE: |
|
|
|
@ -29,22 +29,22 @@ class rcube_ldap extends rcube_addressbook
|
|
|
|
var $conn;
|
|
|
|
var $conn;
|
|
|
|
var $prop = array();
|
|
|
|
var $prop = array();
|
|
|
|
var $fieldmap = array();
|
|
|
|
var $fieldmap = array();
|
|
|
|
|
|
|
|
|
|
|
|
var $filter = '';
|
|
|
|
var $filter = '';
|
|
|
|
var $result = null;
|
|
|
|
var $result = null;
|
|
|
|
var $ldap_result = null;
|
|
|
|
var $ldap_result = null;
|
|
|
|
var $sort_col = '';
|
|
|
|
var $sort_col = '';
|
|
|
|
var $mail_domain = '';
|
|
|
|
var $mail_domain = '';
|
|
|
|
var $debug = false;
|
|
|
|
var $debug = false;
|
|
|
|
|
|
|
|
|
|
|
|
/** public properties */
|
|
|
|
/** public properties */
|
|
|
|
var $primary_key = 'ID';
|
|
|
|
var $primary_key = 'ID';
|
|
|
|
var $readonly = true;
|
|
|
|
var $readonly = true;
|
|
|
|
var $list_page = 1;
|
|
|
|
var $list_page = 1;
|
|
|
|
var $page_size = 10;
|
|
|
|
var $page_size = 10;
|
|
|
|
var $ready = false;
|
|
|
|
var $ready = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Object constructor
|
|
|
|
* Object constructor
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -90,7 +90,7 @@ class rcube_ldap extends rcube_addressbook
|
|
|
|
|
|
|
|
|
|
|
|
if (is_resource($this->conn))
|
|
|
|
if (is_resource($this->conn))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_array($this->prop['hosts']))
|
|
|
|
if (!is_array($this->prop['hosts']))
|
|
|
|
$this->prop['hosts'] = array($this->prop['hosts']);
|
|
|
|
$this->prop['hosts'] = array($this->prop['hosts']);
|
|
|
|
|
|
|
|
|
|
|
@ -134,8 +134,29 @@ class rcube_ldap extends rcube_addressbook
|
|
|
|
list($u, $d) = explode('@', $fu);
|
|
|
|
list($u, $d) = explode('@', $fu);
|
|
|
|
$dc = 'dc='.strtr($d, array('.' => ',dc=')); // hierarchal domain string
|
|
|
|
$dc = 'dc='.strtr($d, array('.' => ',dc=')); // hierarchal domain string
|
|
|
|
|
|
|
|
|
|
|
|
// Replace the bind_dn and base_dn variables.
|
|
|
|
|
|
|
|
$replaces = array('%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u);
|
|
|
|
$replaces = array('%dc' => $dc, '%d' => $d, '%fu' => $fu, '%u' => $u);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->prop['search_base_dn'] && $this->prop['search_filter']) {
|
|
|
|
|
|
|
|
// Search for the dn to use to authenticate
|
|
|
|
|
|
|
|
$this->prop['search_base_dn'] = strtr($this->prop['search_base_dn'], $replaces);
|
|
|
|
|
|
|
|
$this->prop['search_filter'] = strtr($this->prop['search_filter'], $replaces);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_debug("S: searching with base {$this->prop['search_base_dn']} for {$this->prop['search_filter']}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res = ldap_search($this->conn, $this->prop['search_base_dn'], $this->prop['search_filter'], array('uid'));
|
|
|
|
|
|
|
|
if ($res && ($entry = ldap_first_entry($this->conn, $res))) {
|
|
|
|
|
|
|
|
$bind_dn = ldap_get_dn($this->conn, $entry);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_debug("S: search returned dn: $bind_dn");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($bind_dn) {
|
|
|
|
|
|
|
|
$this->prop['bind_dn'] = $bind_dn;
|
|
|
|
|
|
|
|
$dn = ldap_explode_dn($bind_dn, 1);
|
|
|
|
|
|
|
|
$replaces['%dn'] = $dn[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Replace the bind_dn and base_dn variables.
|
|
|
|
$this->prop['bind_dn'] = strtr($this->prop['bind_dn'], $replaces);
|
|
|
|
$this->prop['bind_dn'] = strtr($this->prop['bind_dn'], $replaces);
|
|
|
|
$this->prop['base_dn'] = strtr($this->prop['base_dn'], $replaces);
|
|
|
|
$this->prop['base_dn'] = strtr($this->prop['base_dn'], $replaces);
|
|
|
|
}
|
|
|
|
}
|
|
|
|