mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-01-12 15:00:13 +01:00
query distribution list data too
This commit is contained in:
parent
691afa2b4f
commit
532fb2c51c
@ -99,6 +99,8 @@ $config['LDAP_HELPER_PASSWORD'] = 'xxxxxxx';
|
|||||||
$config['LDAP_MAIL_ATTR'] = 'mail';
|
$config['LDAP_MAIL_ATTR'] = 'mail';
|
||||||
$config['LDAP_ACCOUNT_OBJECTCLASS'] = 'zimbraAccount';
|
$config['LDAP_ACCOUNT_OBJECTCLASS'] = 'zimbraAccount';
|
||||||
$config['LDAP_BASE_DN'] = '';
|
$config['LDAP_BASE_DN'] = '';
|
||||||
|
$config['LDAP_DISTRIBUTIONLIST_OBJECTCLASS'] = 'zimbraDistributionList';
|
||||||
|
$config['LDAP_DISTRIBUTIONLIST_ATTR'] = 'zimbraMailForwardingAddress';
|
||||||
|
|
||||||
$config['SIZE_X'] = 430;
|
$config['SIZE_X'] = 430;
|
||||||
$config['SIZE_Y'] = 250;
|
$config['SIZE_Y'] = 250;
|
||||||
|
@ -66,7 +66,7 @@ class ModelUserAuth extends Model {
|
|||||||
$ldap = new LDAP(LDAP_HOST, LDAP_HELPER_DN, LDAP_HELPER_PASSWORD);
|
$ldap = new LDAP(LDAP_HOST, LDAP_HELPER_DN, LDAP_HELPER_PASSWORD);
|
||||||
|
|
||||||
if($ldap->is_bind_ok()) {
|
if($ldap->is_bind_ok()) {
|
||||||
$query = $ldap->query(LDAP_BASE_DN, "(&(objectClass=" . LDAP_ACCOUNT_OBJECTCLASS . ")(" . LDAP_MAIL_ATTR . "=$username))", array());
|
$query = $ldap->query(LDAP_BASE_DN, "(|(&(objectClass=" . LDAP_ACCOUNT_OBJECTCLASS . ")(" . LDAP_MAIL_ATTR . "=$username))(&(objectClass=" . LDAP_DISTRIBUTIONLIST_OBJECTCLASS . ")(" . LDAP_DISTRIBUTIONLIST_ATTR . "=$username)" . "))", array());
|
||||||
|
|
||||||
if(isset($query->row)) {
|
if(isset($query->row)) {
|
||||||
$a = $query->row;
|
$a = $query->row;
|
||||||
@ -74,7 +74,7 @@ class ModelUserAuth extends Model {
|
|||||||
$ldap_auth = new LDAP(LDAP_HOST, $a['dn'], $password);
|
$ldap_auth = new LDAP(LDAP_HOST, $a['dn'], $password);
|
||||||
|
|
||||||
if($ldap_auth->is_bind_ok()) {
|
if($ldap_auth->is_bind_ok()) {
|
||||||
$emails = $this->get_email_array_from_ldap_attr($a);
|
$emails = $this->get_email_array_from_ldap_attr($query->rows);
|
||||||
|
|
||||||
$this->add_session_vars($a['cn'], $username, $emails);
|
$this->add_session_vars($a['cn'], $username, $emails);
|
||||||
|
|
||||||
@ -95,21 +95,25 @@ class ModelUserAuth extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function get_email_array_from_ldap_attr($a = array(), $email = '') {
|
private function get_email_array_from_ldap_attr($e = array()) {
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
foreach (array("mail", "mailalternateaddress", "proxyaddresses") as $mailattr) {
|
foreach($e as $a) {
|
||||||
|
foreach (array("mail", "mailalternateaddress", "proxyaddresses", LDAP_MAIL_ATTR, LDAP_DISTRIBUTIONLIST_ATTR) as $mailattr) {
|
||||||
if(isset($a[$mailattr])) {
|
if(isset($a[$mailattr])) {
|
||||||
|
|
||||||
if(isset($a[$mailattr]['count'])) {
|
if(isset($a[$mailattr]['count'])) {
|
||||||
for($i = 0; $i < $a[$mailattr]['count']; $i++) {
|
for($i = 0; $i < $a[$mailattr]['count']; $i++) {
|
||||||
if(preg_match("/^smtp\:/i", $a[$mailattr][$i]) || strchr($a[$mailattr][$i], '@') ) {
|
if(preg_match("/^smtp\:/i", $a[$mailattr][$i]) || strchr($a[$mailattr][$i], '@') ) {
|
||||||
array_push($data, strtolower(preg_replace("/^smtp\:/i", "", $a[$mailattr][$i])));
|
$email = strtolower(preg_replace("/^smtp\:/i", "", $a[$mailattr][$i]));
|
||||||
|
if(!in_array($email, $data)) { array_push($data, $email); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
array_push($data, strtolower(preg_replace("/^smtp\:/i", "", $a[$mailattr])));
|
$email = strtolower(preg_replace("/^smtp\:/i", "", $a[$mailattr]));
|
||||||
|
if(!in_array($email, $data)) { array_push($data, $email); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user