* Univention: mail app was not working for in UCS created users

because of not set "mail" attribute, UCS only set "mailPrimaryAddress", changed our code to also use just that attribute
This commit is contained in:
Ralf Becker 2015-02-14 12:56:28 +00:00
parent 3f385e719e
commit b29610c2b9
6 changed files with 105 additions and 78 deletions

View File

@ -261,8 +261,8 @@ class addressbook_ldap
/**
* constructor of the class
*
* @param array $ldap_config=null default use from $GLOBALS['egw_info']['server']
* @param resource $ds=null ldap connection to use
* @param array $ldap_config =null default use from $GLOBALS['egw_info']['server']
* @param resource $ds =null ldap connection to use
*/
function __construct(array $ldap_config=null, $ds=null)
{
@ -292,7 +292,7 @@ class addressbook_ldap
}
$this->ldapServerInfo = $GLOBALS['egw']->ldap->getLDAPServerInfo($this->ldap_config['ldap_contact_host']);
foreach($this->schema2egw as $schema => $attributes)
foreach($this->schema2egw as $attributes)
{
$this->all_attributes = array_merge($this->all_attributes,array_values($attributes));
}
@ -312,7 +312,7 @@ class addressbook_ldap
/**
* connect to LDAP server
*
* @param boolean $admin=false true (re-)connect with admin not user credentials, eg. to modify accounts
* @param boolean $admin =false true (re-)connect with admin not user credentials, eg. to modify accounts
*/
function connect($admin = false)
{
@ -395,7 +395,7 @@ class addressbook_ldap
/**
* reads contact data
*
* @param string/array $contact_id contact_id or array with values for id or account_id
* @param string|array $contact_id contact_id or array with values for id or account_id
* @return array/boolean data if row could be retrived else False
*/
function read($contact_id)
@ -444,11 +444,9 @@ class addressbook_ldap
{
$this->data = is_array($this->data) ? array_merge($this->data,$keys) : $keys;
}
$contactUID = '';
$data =& $this->data;
$isUpdate = false;
$newObjectClasses = array();
$ldapContact = array();
// generate addressbook dn
@ -494,7 +492,7 @@ class addressbook_ldap
$contactUID = $this->data[$this->contacts_id];
if (!empty($contactUID) &&
($result = ldap_search($this->ds, $base=$this->allContactsDN, $filter=$this->id_filter($contactUID), $attributes)) &&
($result = ldap_search($this->ds, $base=$this->allContactsDN, $this->id_filter($contactUID), $attributes)) &&
($oldContactInfo = ldap_get_entries($this->ds, $result)) && $oldContactInfo['count'])
{
unset($oldContactInfo[0]['objectclass']['count']);
@ -591,8 +589,8 @@ class addressbook_ldap
if ($needRecreation)
{
$result = ldap_read($this->ds, $dn, 'objectclass=*');
$oldContact = ldap_get_entries($this->ds, $result);
$oldContact = ldap::result2array($oldContact[0]);
$entries = ldap_get_entries($this->ds, $result);
$oldContact = ldap::result2array($entries[0]);
unset($oldContact['dn']);
$newContact = $oldContact;
@ -681,8 +679,8 @@ class addressbook_ldap
foreach($keys as $entry)
{
$entry = ldap::quote(is_array($entry) ? $entry['id'] : $entry);
if($result = ldap_search($this->ds, $this->allContactsDN,
"(|(entryUUID=$entry)(uid=$entry))", $attributes))
if(($result = ldap_search($this->ds, $this->allContactsDN,
"(|(entryUUID=$entry)(uid=$entry))", $attributes)))
{
$contactInfo = ldap_get_entries($this->ds, $result);
if(@ldap_delete($this->ds, $contactInfo[0]['dn']))
@ -699,23 +697,25 @@ class addressbook_ldap
*
* '*' and '?' are replaced with sql-wildcards '%' and '_'
*
* @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
* @param boolean/string $only_keys=true True returns only keys, False returns all cols. comma seperated list of keys to return
* @param string $order_by='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
* @param string/array $extra_cols='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
* @param string $wildcard='' appended befor and after each criteria
* @param boolean $empty=false False=empty criteria are ignored in query, True=empty have to be empty in row
* @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
* @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num)
* @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
* @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
* @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
* @param boolean|string $only_keys =true True returns only keys, False returns all cols. comma seperated list of keys to return
* @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
* @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
* @param string $wildcard ='' appended befor and after each criteria
* @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row
* @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
* @param mixed $start =false if != false, return only maxmatch rows begining with start, or array($start,$num)
* @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
* @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
* "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
* @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false
* @param boolean $need_full_no_count =false If true an unlimited query is run to determine the total number of rows, default false
* @return array of matching rows (the row is an array of the cols) or False
*/
function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
{
//error_log(__METHOD__."(".array2string($criteria).", ".array2string($only_keys).", '$order_by', ".array2string($extra_cols).", '$wildcard', '$empty', '$op', ".array2string($start).", ".array2string($filter).")");
unset($only_keys, $extra_cols, $empty, $join, $need_full_no_count); // not used, but required by function signature
if (is_array($filter['owner']))
{
if (count($filter['owner']) == 1)
@ -738,6 +738,7 @@ class addressbook_ldap
);
foreach($filter as $key => $value)
{
$matches = null;
if (is_int($key) && preg_match('/^(contact_)?(modified|created)([<=>]+)([0-9]+)$/', $value, $matches))
{
$append = '';
@ -952,6 +953,7 @@ class addressbook_ldap
break;
default:
$matches = null;
if (!is_int($key))
{
foreach($this->schema2egw as $mapping)
@ -996,7 +998,7 @@ class addressbook_ldap
* @param string $_filter
* @param array $_attributes
* @param int $_addressbooktype
* @param array $_skipPlugins=null schema-plugins to skip
* @param array $_skipPlugins =null schema-plugins to skip
* @return array/boolean with eGW contacts or false on error
*/
function _searchLDAP($_ldapContext, $_filter, $_attributes, $_addressbooktype, array $_skipPlugins=null)
@ -1062,6 +1064,7 @@ class addressbook_ldap
$bin = ldap_get_values_len($this->ds,ldap_first_entry($this->ds,$result),'jpegphoto');
$contact['jpegphoto'] = $bin[0];
}
$matches = null;
if(preg_match('/cn=([^,]+),'.preg_quote($this->personalContactsDN,'/').'$/i',$entry['dn'],$matches))
{
// personal addressbook
@ -1269,6 +1272,7 @@ class addressbook_ldap
*/
function _inetorgperson2egw(&$contact, $data, $cn='cn')
{
$matches = null;
if(empty($data['givenname'][0]))
{
$parts = explode($data['sn'][0], $data[$cn][0]);
@ -1301,7 +1305,8 @@ class addressbook_ldap
*/
function _posixaccount2egw(&$contact,$data)
{
static $shadowExpireNow;
unset($contact); // not used, but required by function signature
static $shadowExpireNow=null;
if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time()-date('Z'))/86400);
// exclude expired or deactivated accounts
@ -1369,6 +1374,7 @@ class addressbook_ldap
*/
function _mozillaorgperson2egw(&$contact,$data)
{
unset($contact, $data); // not used, but required by function signature
// no special handling necessary, as it supports two distinct attributes: c, cn
}

View File

@ -10,11 +10,17 @@
*/
/**
* Univention backend for accounts
* Univention backend for addressbook
*
* There's currently no difference to LDAP backend
* Different mail attribute is only difference to LDAP backend
*/
class addressbook_univention extends addressbook_ldap
{
function __construct($ldap_config = null, $ds = null)
{
$this->schema2egw['univentionmail'] = array(
'email' => accounts_univention::MAIL_ATTR,
);
parent::__construct($ldap_config, $ds);
}
}

View File

@ -5,7 +5,7 @@
* @link http://www.stylite.de
* @package emailadmin
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2010-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2010-15 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -43,6 +43,11 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
*/
const GROUP_SCHEMA = 'posixGroup';
/**
* Attribute with mail address(es)
*/
const MAIL_ATTR = 'mail';
/**
* Attribute to enable mail for an account, OR false if existence of ALIAS_ATTR is enough for mail delivery
*/
@ -144,7 +149,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
/**
* Constructor
*
* @param string $defaultDomain=null
* @param string $defaultDomain =null
*/
function __construct($defaultDomain=null)
{
@ -218,7 +223,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
}
// the new code for postfix+cyrus+ldap
$newData = array(
'mail' => $mailLocalAddress,
static::MAIL_ATTR => $mailLocalAddress,
'objectclass' => $objectClasses
);
// does schema have explicit alias attribute AND require mail added as alias too
@ -273,7 +278,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
$emailAddresses = array();
$ds = $this->getLdapConnection();
$filter = '(&'.static::USER_FILTER.'('.static::USER_ATTR.'='.ldap::quote($_accountName).'))';
$attributes = array('dn', 'mail', static::ALIAS_ATTR);
$attributes = array('dn', static::MAIL_ATTR, static::ALIAS_ATTR);
$sri = @ldap_search($ds, $this->search_base, $filter, $attributes);
if ($sri)
@ -281,9 +286,9 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
$realName = trim($GLOBALS['egw_info']['user']['account_firstname'] . (!empty($GLOBALS['egw_info']['user']['account_firstname']) ? ' ' : '') . $GLOBALS['egw_info']['user']['account_lastname']);
$allValues = ldap_get_entries($ds, $sri);
if(isset($allValues[0]['mail']))
if(isset($allValues[0][static::MAIL_ATTR]))
{
foreach($allValues[0]['mail'] as $key => $value)
foreach($allValues[0][static::MAIL_ATTR] as $key => $value)
{
if ($key === 'count') continue;
@ -319,7 +324,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
* from all accounts!
*
* @param int|string $user numerical account-id, account-name or email address
* @param boolean $match_uid_at_domain=true true: uid@domain matches, false only an email or alias address matches
* @param boolean $match_uid_at_domain =true true: uid@domain matches, false only an email or alias address matches
* @return array with values for keys 'mailLocalAddress', 'mailAlternateAddress' (array), 'mailForwardingAddress' (array),
* 'accountStatus' ("active"), 'quotaLimit' and 'deliveryMode' ("forwardOnly")
*/
@ -355,7 +360,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
}
else
{
$to_or = array('(mail='.ldap::quote($user).')');
$to_or = array('('.static::MAIL_ATTR.'='.ldap::quote($user).')');
if ($match_uid_at_domain) $to_or[] = '('.static::USER_ATTR.'='.ldap::quote($namepart).')';
if (static::ALIAS_ATTR)
{
@ -372,7 +377,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
}
}
$attributes = array_values(array_diff(array(
'mail', 'objectclass', static::USER_ATTR, static::MAIL_ENABLE_ATTR, static::ALIAS_ATTR,
static::MAIL_ATTR, 'objectclass', static::USER_ATTR, static::MAIL_ENABLE_ATTR, static::ALIAS_ATTR,
static::MAILBOX_ATTR, static::FORWARD_ATTR, static::FORWARD_ONLY_ATTR, static::QUOTA_ATTR,
), array(false, '')));
@ -400,12 +405,12 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
$accountStatus = isset($values[static::MAIL_ENABLE_ATTR]) &&
(static::MAIL_ENABLED === self::MAIL_ENABLED_USE_MAIL && !empty($values[static::MAIL_ENABLE_ATTR][0]) ||
static::MAIL_ENABLED && !strcasecmp($values[static::MAIL_ENABLE_ATTR][0], static::MAIL_ENABLED) ||
!static::MAIL_ENABLED && $values[static::ALIAS_ATTR ? static::ALIAS_ATTR : 'mail']['count'] > 0) ?
!static::MAIL_ENABLED && $values[static::ALIAS_ATTR ? static::ALIAS_ATTR : static::MAIL_ATTR]['count'] > 0) ?
emailadmin_smtp::MAIL_ENABLED : '';
}
else
{
$accountStatus = $values[static::ALIAS_ATTR ? static::ALIAS_ATTR : 'mail']['count'] > 0 ?
$accountStatus = $values[static::ALIAS_ATTR ? static::ALIAS_ATTR : static::MAIL_ATTR]['count'] > 0 ?
emailadmin_smtp::MAIL_ENABLED : '';
}
if (static::FORWARD_ONLY_ATTR)
@ -449,7 +454,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
// regular user-data can only be from users, NOT groups
if (in_array(static::GROUP_SCHEMA, $values['objectclass'])) continue;
$userData['mailLocalAddress'] = $values['mail'][0];
$userData['mailLocalAddress'] = $values[static::MAIL_ATTR][0];
$userData['accountStatus'] = $accountStatus;
if (static::ALIAS_ATTR)
@ -458,7 +463,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
}
else
{
$userData['mailAlternateAddress'] = (array)$values['mail'];
$userData['mailAlternateAddress'] = (array)$values[static::MAIL_ATTR];
unset($userData['mailAlternateAddress']['count']);
unset($userData['mailAlternateAddress'][0]);
$userData['mailAlternateAddress'] = array_values($userData['mailAlternateAddress']);
@ -503,8 +508,8 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
* @param string $_accountStatus
* @param string $_mailLocalAddress
* @param int $_quota in MB
* @param boolean $_forwarding_only=false not used as we have our own addAccount method
* @param string $_setMailbox=null used only for account migration
* @param boolean $_forwarding_only =false not used as we have our own addAccount method
* @param string $_setMailbox =null used only for account migration
* @return boolean true on success, false on error writing to ldap
*/
function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode,
@ -544,7 +549,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
sort($_mailAlternateAddress);
sort($_mailForwardingAddress);
$newData['mail'] = $_mailLocalAddress;
$newData[static::MAIL_ATTR] = $_mailLocalAddress;
// does schema have explicit alias attribute
if (static::ALIAS_ATTR)
{
@ -559,7 +564,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
// or de we add them - if existing - to mail attr
elseif ($_mailAlternateAddress)
{
self::setAttributePrefix($newData['mail'], $_mailAlternateAddress, static::ALIAS_PREFIX);
self::setAttributePrefix($newData[static::MAIL_ATTR], $_mailAlternateAddress, static::ALIAS_PREFIX);
}
// does schema support to store forwards
if (static::FORWARD_ATTR)
@ -705,8 +710,8 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
function getMailboxes($return_inactive)
{
$ds = $this->getLdapConnection();
$filter = array("(mail=*)");
$attrs = array(static::USER_ATTR, 'mail');
$filter = array('('.static::MAIL_ATTR.'=*)');
$attrs = array(static::USER_ATTR, static::MAIL_ATTR);
if (static::MAILBOX_ATTR)
{
$filter[] = '('.static::MAILBOX_ATTR.'=*)';
@ -737,7 +742,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
foreach($entries as $entry)
{
if ($entry[static::USER_ATTR][0] == 'anonymous') continue; // anonymous is never a mail-user!
list($mailbox) = explode('@', $entry[static::MAILBOX_ATTR ? static::MAILBOX_ATTR : 'mail'][0]);
list($mailbox) = explode('@', $entry[static::MAILBOX_ATTR ? static::MAILBOX_ATTR : static::MAIL_ATTR][0]);
$mailboxes[$entry[static::USER_ATTR][0]] = $mailbox;
}
return $mailboxes;
@ -748,7 +753,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
*
* @param array &$attribute on return array with values set and existing values preseved
* @param string|array $values value(s) to set
* @param string $prefix='' prefix to use or ''
* @param string $prefix ='' prefix to use or ''
*/
protected static function setAttributePrefix(&$attribute, $values, $prefix='')
{
@ -767,8 +772,8 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
* Get values having an optional prefix from a given LDAP attribute
*
* @param array &$attribute only "count" and prefixed values get removed, get's reindexed, if values have been removed
* @param string $prefix='' prefix to use or ''
* @param boolean $remove=true remove returned values from $attribute
* @param string $prefix ='' prefix to use or ''
* @param boolean $remove =true remove returned values from $attribute
* @return array with values (prefix removed) or array() if nothing found
*/
protected static function getAttributePrefix(&$attribute, $prefix='', $remove=true)

View File

@ -5,8 +5,8 @@
* @link http://www.egroupware.org
* @package emailadmin
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2014 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id4$
* @copyright (c) 2014-15 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/
/**
@ -24,6 +24,11 @@ class emailadmin_smtp_univention extends emailadmin_smtp_ldap
*/
const SCHEMA = 'univentionMail';
/**
* Attribute with mail address
*/
const MAIL_ATTR = 'mailprimaryaddress';
/**
* Attribute to enable mail for an account, OR false if existence of ALIAS_ATTR is enough for mail delivery
*/

View File

@ -40,6 +40,10 @@
*/
class accounts_ldap
{
/**
* Name of mail attribute
*/
const MAIL_ATTR = 'mail';
/**
* resource with connection to the ldap server
*
@ -84,7 +88,7 @@ class accounts_ldap
),
'user-if-supported' => array( // these classes get added, if server supports them
'mozillaabpersonalpha', 'mozillaorgperson', 'evolutionperson',
'univentionperson', array('univentionobject', 'univentionObjectType' => 'users/user'),
'univentionperson', 'univentionmail', array('univentionobject', 'univentionObjectType' => 'users/user'),
),
'group' => array(
'top','posixgroup','groupofnames'
@ -97,10 +101,9 @@ class accounts_ldap
* Classes allowing to set a mail-address for a group and specify the memberaddresses as forwarding addresses
*
* $objectclass => $forward
* $objectclass => [$forward, $extra_attr, $mail_attr, $keep_objectclass]
* $objectclass => [$forward, $extra_attr, $keep_objectclass]
* $forward : name of attribute to set forwards for members mail addresses, false if not used/required
* $extra_attr : required attribute (eg. 'uid'), which need to be set, default none
* $mail_attr : name of attribute for mail-address, if not 'mail'
* $keep_objectclass : true to not remove objectclass, if not mail set
*
* @var array
@ -110,7 +113,7 @@ class accounts_ldap
'dbmailuser' => array('mailforwardingaddress','uid'),
'qmailuser' => array('mailforwardingaddress','uid'),
'mailaccount' => 'mailalias',
'univentiongroup' => array(false, false, 'mailprimaryaddress', true),
'univentiongroup' => array(false, false, true),
);
/**
@ -294,12 +297,11 @@ class accounts_ldap
foreach($this->group_mail_classes as $objectclass => $forward)
{
$extra_attr = false;
$mail_attr = 'mail';
$keep_objectclass = false;
if (is_array($forward)) list($forward,$extra_attr,$mail_attr,$keep_objectclass) = $forward;
if (is_array($forward)) list($forward,$extra_attr,$keep_objectclass) = $forward;
if ($this->ldapServerInfo->supportsObjectClass($objectclass) &&
($old && in_array($objectclass,$old['objectclass']) || $data_utf8['account_email'] || $old[$mail_attr]))
($old && in_array($objectclass,$old['objectclass']) || $data_utf8['account_email'] || $old[static::MAIL_ATTR]))
{
if ($data_utf8['account_email']) // setting an email
{
@ -309,7 +311,7 @@ class accounts_ldap
$to_write['objectclass'][] = $objectclass;
}
if ($extra_attr) $to_write[$extra_attr] = $data_utf8['account_lid'];
$to_write[$mail_attr] = $data_utf8['account_email'];
$to_write[static::MAIL_ATTR] = $data_utf8['account_email'];
if ($forward)
{
@ -326,7 +328,7 @@ class accounts_ldap
}
elseif($old) // remove the mail and forwards only for existing entries
{
$to_write[$mail_attr] = array();
$to_write[static::MAIL_ATTR] = array();
if ($forward) $to_write[$forward] = array();
if ($extra_attr) $to_write[$extra_attr] = array();
if (!$keep_objectclass && ($key = array_search($objectclass,$old['objectclass'])))
@ -345,11 +347,11 @@ class accounts_ldap
{
$to_write = $this->_merge_user($to_write,$data_utf8,!$old);
// make sure multiple email-addresses in the mail attribute "survive"
if (isset($to_write['mail']) && count($old['mail']) > 1)
if (isset($to_write[static::MAIL_ATTR]) && count($old[static::MAIL_ATTR]) > 1)
{
$mail = $old['mail'];
$mail[0] = $to_write['mail'];
$to_write['mail'] = array_values(array_unique($mail));
$mail = $old[static::MAIL_ATTR];
$mail[0] = $to_write[static::MAIL_ATTR];
$to_write[static::MAIL_ATTR] = array_values(array_unique($mail));
}
$data['account_type'] = 'u';
@ -430,23 +432,21 @@ class accounts_ldap
*/
protected function _read_group($account_id)
{
$mail_attr = 'mail';
$group = array();
if (!is_object($this->ldapServerInfo))
{
$this->ldapServerInfo = $this->ldap->getLDAPServerInfo($this->frontend->config['ldap_host']);
}
foreach($this->group_mail_classes as $objectclass => $attrs)
foreach(array_keys($this->group_mail_classes) as $objectclass)
{
if ($this->ldapServerInfo->supportsObjectClass($objectclass))
{
$group['mailAllowed'] = $objectclass;
if (is_array($attrs) && $attrs[2]) $mail_attr = $attrs[2];
break;
}
}
$sri = ldap_search($this->ds, $this->group_context,'(&(objectClass=posixGroup)(gidnumber=' . abs($account_id).'))',
array('dn', 'gidnumber', 'cn', 'objectclass', $mail_attr, 'memberuid'));
array('dn', 'gidnumber', 'cn', 'objectclass', static::MAIL_ATTR, 'memberuid'));
$ldap_data = ldap_get_entries($this->ds, $sri);
if (!$ldap_data['count'])
@ -465,7 +465,7 @@ class accounts_ldap
'account_lastname' => lang('Group'),
'account_fullname' => lang('Group').' '.$data['cn'][0],
'objectclass' => array_map('strtolower', $data['objectclass']),
'account_email' => $data[$mail_attr][0],
'account_email' => $data[static::MAIL_ATTR][0],
'members' => array(),
);
@ -495,7 +495,7 @@ class accounts_ldap
protected function _read_user($account_id)
{
$sri = ldap_search($this->ds, $this->user_context, '(&(objectclass=posixAccount)(uidnumber=' . (int)$account_id.'))',
array('dn','uidnumber','uid','gidnumber','givenname','sn','cn','mail','userpassword','telephonenumber',
array('dn','uidnumber','uid','gidnumber','givenname','sn','cn',static::MAIL_ATTR,'userpassword','telephonenumber',
'shadowexpire','shadowlastchange','homedirectory','loginshell','createtimestamp','modifytimestamp'));
$ldap_data = ldap_get_entries($this->ds, $sri);
@ -514,7 +514,7 @@ class accounts_ldap
'account_primary_group' => -$data['gidnumber'][0],
'account_firstname' => $data['givenname'][0],
'account_lastname' => $data['sn'][0],
'account_email' => $data['mail'][0],
'account_email' => $data[static::MAIL_ATTR][0],
'account_fullname' => $data['cn'][0],
'account_pwd' => $data['userpassword'][0],
'account_phone' => $data['telephonenumber'][0],
@ -581,7 +581,7 @@ class accounts_ldap
$to_write['sn'] = $data['account_lastname'];
if (!$new_entry || $data['account_email'])
{
$to_write['mail'] = $data['account_email'] ? $data['account_email'] : array();
$to_write[static::MAIL_ATTR] = $data['account_email'] ? $data['account_email'] : array();
}
$to_write['cn'] = $data['account_fullname'] ? $data['account_fullname'] : $data['account_firstname'].' '.$data['account_lastname'];
@ -707,7 +707,7 @@ class accounts_ldap
'firstname' => 'givenname',
'lastname' => 'sn',
'lid' => 'uid',
'email' => 'mail',
'email' => static::MAIL_ATTR,
);
$filter .= '('.$to_ldap[$param['query_type']].'=*'.$query.'*)';
break;
@ -761,7 +761,7 @@ class accounts_ldap
$filter = '(&(objectclass=posixaccount)(|(uid='.implode(')(uid=',$relevantAccounts).'))' . $this->account_filter.')';
$filter = str_replace(array('%user','%domain'),array('*',$GLOBALS['egw_info']['user']['domain']),$filter);
}
$sri = ldap_search($this->ds, $this->user_context, $filter,array('uid','uidNumber','givenname','sn','mail','shadowExpire','createtimestamp','modifytimestamp','objectclass','gidNumber'));
$sri = ldap_search($this->ds, $this->user_context, $filter,array('uid','uidNumber','givenname','sn',static::MAIL_ATTR,'shadowExpire','createtimestamp','modifytimestamp','objectclass','gidNumber'));
//echo "<p>ldap_search(,$this->user_context,'$filter',) ".($sri ? '' : ldap_error($this->ds)).microtime()."</p>\n";
$utc_diff = date('Z');
@ -779,7 +779,7 @@ class accounts_ldap
'account_lastname' => translation::convert($allVals['sn'][0],'utf-8'),
'account_status' => isset($allVals['shadowexpire'][0]) && $allVals['shadowexpire'][0]*24*3600-$utc_diff < time() ? false : 'A',
'account_expires' => isset($allVals['shadowexpire']) && $allVals['shadowexpire'][0] ? $allVals['shadowexpire'][0]*24*3600+$utc_diff : -1, // LDAP date is in UTC
'account_email' => $allVals['mail'][0],
'account_email' => $allVals[static::MAIL_ATTR][0],
'account_created' => isset($allVals['createtimestamp'][0]) ? self::accounts_ldap2ts($allVals['createtimestamp'][0]) : null,
'account_modified' => isset($allVals['modifytimestamp'][0]) ? self::accounts_ldap2ts($allVals['modifytimestamp'][0]) : null,
'account_primary_group' => (string)-$allVals['gidnumber'][0],
@ -954,7 +954,7 @@ class accounts_ldap
}
$to_ldap = array(
'account_lid' => 'uid',
'account_email' => 'mail',
'account_email' => static::MAIL_ATTR,
'account_fullname' => 'cn',
);
if (!isset($to_ldap[$which]) || $account_type === 'g') {

View File

@ -20,6 +20,11 @@
*/
class accounts_univention extends accounts_ldap
{
/**
* Attribute with mail address
*/
const MAIL_ATTR = 'mailprimaryaddress';
/**
* Name of binary to call
*/