mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-20 18:08:02 +02:00
allow to copy uid and just set an attribute eg. "attributes={\\server\\homes\\}homeDirectory=uid,{H:}homeDrive="
This commit is contained in:
parent
8beb0a0a6a
commit
ed24fa796d
@ -259,12 +259,16 @@ class setup_cmd_ldap extends setup_cmd
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
list($to, $from) = explode('=', $attr);
|
list($to, $from) = explode('=', $attr);
|
||||||
$attrs[] = $from;
|
if ($from) $attrs[] = $from;
|
||||||
$rename[strtolower($from)] = $to;
|
$rename[strtolower($from)] = $to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ignore_attr = array_flip(array('dn', 'objectclass', 'cn', 'userpassword'));
|
||||||
|
if (!in_array('uid', $attrs))
|
||||||
|
{
|
||||||
$attrs[] = 'uid'; // need to match account
|
$attrs[] = 'uid'; // need to match account
|
||||||
|
$ignore_attr['uid'] = true;
|
||||||
|
}
|
||||||
// connect to destination ads
|
// connect to destination ads
|
||||||
if (empty($this->ads_context))
|
if (empty($this->ads_context))
|
||||||
{
|
{
|
||||||
@ -309,7 +313,6 @@ class setup_cmd_ldap extends setup_cmd
|
|||||||
{
|
{
|
||||||
throw new egw_exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search));
|
throw new egw_exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search));
|
||||||
}
|
}
|
||||||
|
|
||||||
$changed = 0;
|
$changed = 0;
|
||||||
foreach($entries as $key => $entry)
|
foreach($entries as $key => $entry)
|
||||||
{
|
{
|
||||||
@ -317,7 +320,7 @@ class setup_cmd_ldap extends setup_cmd
|
|||||||
|
|
||||||
$entry = ldap::result2array($entry);
|
$entry = ldap::result2array($entry);
|
||||||
$uid = $entry['uid'];
|
$uid = $entry['uid'];
|
||||||
$entry = array_diff_key($entry, array_flip(array('dn', 'uid', 'objectclass', 'cn', 'userpassword')));
|
$entry = array_diff_key($entry, $ignore_attr);
|
||||||
|
|
||||||
if (!($sr = ldap_search($ads->ds, $this->ads_context,
|
if (!($sr = ldap_search($ads->ds, $this->ads_context,
|
||||||
$search='(&(objectClass=user)(sAMAccountName='.ldap::quote($uid).'))', array('dn'))) ||
|
$search='(&(objectClass=user)(sAMAccountName='.ldap::quote($uid).'))', array('dn'))) ||
|
||||||
@ -327,10 +330,11 @@ class setup_cmd_ldap extends setup_cmd
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$dn = $dest[0]['dn'];
|
$dn = $dest[0]['dn'];
|
||||||
|
if (isset($rename[''])) $entry[''] = '';
|
||||||
$update = array();
|
$update = array();
|
||||||
foreach($entry as $attr => $value)
|
foreach($entry as $attr => $value)
|
||||||
{
|
{
|
||||||
if ($value)
|
if ($value || $attr === '')
|
||||||
{
|
{
|
||||||
$to = isset($rename[$attr]) ? $rename[$attr] : $attr;
|
$to = isset($rename[$attr]) ? $rename[$attr] : $attr;
|
||||||
// special handling for copying shadowExpires to accountExpires (not set or 0 is handled by classicupgrade!)
|
// special handling for copying shadowExpires to accountExpires (not set or 0 is handled by classicupgrade!)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user