Changeset View
Changeset View
Standalone View
Standalone View
plugins/libkolab/lib/kolab_ldap.php
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | private function _connect() | ||||
// with OpenLDAP 2.x ldap_connect() always succeeds but ldap_bind will fail if host isn't reachable | // with OpenLDAP 2.x ldap_connect() always succeeds but ldap_bind will fail if host isn't reachable | ||||
// see http://www.php.net/manual/en/function.ldap-connect.php | // see http://www.php.net/manual/en/function.ldap-connect.php | ||||
foreach ((array)$this->config['hosts'] as $host) { | foreach ((array)$this->config['hosts'] as $host) { | ||||
// skip host if connection failed | // skip host if connection failed | ||||
if (!$this->connect($host)) { | if (!$this->connect($host)) { | ||||
continue; | continue; | ||||
} | } | ||||
$bind_pass = $this->config['bind_pass']; | $bind_pass = $this->config['bind_pass'] ?? null; | ||||
$bind_user = $this->config['bind_user']; | $bind_user = $this->config['bind_user'] ?? null; | ||||
$bind_dn = $this->config['bind_dn']; | $bind_dn = $this->config['bind_dn']; | ||||
$base_dn = $this->config['base_dn']; | $base_dn = $this->config['base_dn']; | ||||
$groups_base_dn = $this->config['groups']['base_dn'] ?: $base_dn; | $groups_base_dn = $this->config['groups']['base_dn'] ?: $base_dn; | ||||
// User specific access, generate the proper values to use. | // User specific access, generate the proper values to use. | ||||
if ($this->config['user_specific']) { | if ($this->config['user_specific']) { | ||||
$rcube = rcube::get_instance(); | $rcube = rcube::get_instance(); | ||||
// No password set, use the session password | // No password set, use the session password | ||||
if (empty($bind_pass)) { | if (empty($bind_pass)) { | ||||
$bind_pass = $rcube->get_user_password(); | $bind_pass = $rcube->get_user_password(); | ||||
} | } | ||||
$u = null; | |||||
// Get the pieces needed for variable replacement. | // Get the pieces needed for variable replacement. | ||||
if ($fu = ($rcube->get_user_email() ?: $this->config['username'])) { | if ($fu = ($rcube->get_user_email() ?: ($this->config['username'] ?? null))) { | ||||
list($u, $d) = explode('@', $fu); | list($u, $d) = explode('@', $fu); | ||||
} | } | ||||
else { | else { | ||||
$d = $this->config['mail_domain']; | $d = $this->config['mail_domain'] ?? null; | ||||
} | } | ||||
$dc = 'dc=' . strtr($d, array('.' => ',dc=')); // hierarchal domain string | $dc = 'dc=' . strtr($d, array('.' => ',dc=')); // hierarchal domain string | ||||
// resolve $dc through LDAP | // resolve $dc through LDAP | ||||
if (!empty($this->config['domain_filter']) && !empty($this->config['search_bind_dn'])) { | if (!empty($this->config['domain_filter']) && !empty($this->config['search_bind_dn'])) { | ||||
$this->bind($this->config['search_bind_dn'], $this->config['search_bind_pw']); | $this->bind($this->config['search_bind_dn'], $this->config['search_bind_pw']); | ||||
$dc = $this->domain_root_dn($d); | $dc = $this->domain_root_dn($d); | ||||
▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | function parse_vars($str, $user = null, $host = null) | ||||
// When authenticating user $user is always set | // When authenticating user $user is always set | ||||
// if not set it means we use this LDAP object for other | // if not set it means we use this LDAP object for other | ||||
// purposes, e.g. kolab_delegation, then username with | // purposes, e.g. kolab_delegation, then username with | ||||
// correct domain is in a session | // correct domain is in a session | ||||
if (!$user) { | if (!$user) { | ||||
$user = $_SESSION['username']; | $user = $_SESSION['username']; | ||||
} | } | ||||
$dc = null; | |||||
if (isset($this->icache[$user])) { | if (isset($this->icache[$user])) { | ||||
list($user, $dc) = $this->icache[$user]; | list($user, $dc) = $this->icache[$user]; | ||||
} | } | ||||
else { | else { | ||||
$orig_user = $user; | $orig_user = $user; | ||||
$rcmail = rcube::get_instance(); | $rcmail = rcube::get_instance(); | ||||
// get default domain | // get default domain | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |