mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-11 08:28:43 +01:00
Cleanup badfilter on empty values; cleanup formatting
This commit is contained in:
parent
286c8bf012
commit
0039d2a51c
@ -39,6 +39,10 @@
|
|||||||
function accounts_()
|
function accounts_()
|
||||||
{
|
{
|
||||||
$this->ds = $GLOBALS['phpgw']->common->ldapConnect();
|
$this->ds = $GLOBALS['phpgw']->common->ldapConnect();
|
||||||
|
if(!@is_object($GLOBALS['phpgw']->translation))
|
||||||
|
{
|
||||||
|
$GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation');
|
||||||
|
}
|
||||||
$this->user_context = $GLOBALS['phpgw_info']['server']['ldap_context'];
|
$this->user_context = $GLOBALS['phpgw_info']['server']['ldap_context'];
|
||||||
$this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
|
$this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
|
||||||
}
|
}
|
||||||
@ -48,13 +52,13 @@
|
|||||||
$acct_type = $this->get_type($this->account_id);
|
$acct_type = $this->get_type($this->account_id);
|
||||||
|
|
||||||
/* search the dn for the given uid */
|
/* search the dn for the given uid */
|
||||||
if ( ($acct_type == 'g') && $this->group_context )
|
if(($acct_type == 'g') && $this->group_context)
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber='.$this->account_id);
|
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber=' . (int)$this->account_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber='.$this->account_id);
|
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$this->account_id);
|
||||||
}
|
}
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
@ -99,13 +103,13 @@
|
|||||||
$acct_type = $this->get_type($this->account_id);
|
$acct_type = $this->get_type($this->account_id);
|
||||||
|
|
||||||
/* search the dn for the given u/gidnumber */
|
/* search the dn for the given u/gidnumber */
|
||||||
if ( ($acct_type == 'g') && $this->group_context )
|
if(($acct_type == 'g') && $this->group_context)
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber='.$this->account_id);
|
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber=' . (int)$this->account_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber='.$this->account_id);
|
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$this->account_id);
|
||||||
}
|
}
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
@ -116,19 +120,27 @@
|
|||||||
// data for posixaccount
|
// data for posixaccount
|
||||||
$newData['cn'] = $GLOBALS['phpgw']->translation->convert(sprintf("%s %s",
|
$newData['cn'] = $GLOBALS['phpgw']->translation->convert(sprintf("%s %s",
|
||||||
$this->data['firstname'],
|
$this->data['firstname'],
|
||||||
$this->data['lastname']),$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
$this->data['lastname']),$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||||
|
);
|
||||||
$newData['uid'] = $GLOBALS['phpgw']->translation->convert(
|
$newData['uid'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
$this->data['account_lid'],
|
$this->data['account_lid'],
|
||||||
$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||||
|
);
|
||||||
if($this->data['lastname'])
|
if($this->data['lastname'])
|
||||||
|
{
|
||||||
$newData['sn'] = $GLOBALS['phpgw']->translation->convert(
|
$newData['sn'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
$this->data['lastname'],
|
$this->data['lastname'],
|
||||||
$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->data['firstname'])
|
if($this->data['firstname'])
|
||||||
|
{
|
||||||
$newData['givenname'] = $GLOBALS['phpgw']->translation->convert(
|
$newData['givenname'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
$this->data['firstname'],
|
$this->data['firstname'],
|
||||||
$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||||
|
);
|
||||||
|
}
|
||||||
if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
|
if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
|
||||||
{
|
{
|
||||||
$newData['homedirectory'] = $this->data['homedirectory'];
|
$newData['homedirectory'] = $this->data['homedirectory'];
|
||||||
@ -141,19 +153,33 @@
|
|||||||
$entry['loginshell'] = '/bin/false';
|
$entry['loginshell'] = '/bin/false';
|
||||||
}
|
}
|
||||||
if($this->data['account_primary_group'])
|
if($this->data['account_primary_group'])
|
||||||
|
{
|
||||||
$newData['gidnumber'] = $this->data['account_primary_group'];
|
$newData['gidnumber'] = $this->data['account_primary_group'];
|
||||||
|
}
|
||||||
if($this->data['lastlogin'])
|
if($this->data['lastlogin'])
|
||||||
|
{
|
||||||
$newData['phpgwaccountlastlogin'] = $this->data['lastlogin'];
|
$newData['phpgwaccountlastlogin'] = $this->data['lastlogin'];
|
||||||
|
}
|
||||||
if($this->data['lastloginfrom'])
|
if($this->data['lastloginfrom'])
|
||||||
|
{
|
||||||
$newData['phpgwaccountlastloginfrom'] = $this->data['lastloginfrom'];
|
$newData['phpgwaccountlastloginfrom'] = $this->data['lastloginfrom'];
|
||||||
|
}
|
||||||
if($this->data['lastpasswd_change'])
|
if($this->data['lastpasswd_change'])
|
||||||
|
{
|
||||||
$newData['phpgwlastpasswdchange'] = $this->data['lastpasswd_change'];
|
$newData['phpgwlastpasswdchange'] = $this->data['lastpasswd_change'];
|
||||||
|
}
|
||||||
if($this->data['status'])
|
if($this->data['status'])
|
||||||
|
{
|
||||||
$newData['phpgwaccountstatus'] = $this->data['status'];
|
$newData['phpgwaccountstatus'] = $this->data['status'];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$newData['phpgwaccountstatus'] = array();
|
$newData['phpgwaccountstatus'] = array();
|
||||||
|
}
|
||||||
if($this->data['expires'])
|
if($this->data['expires'])
|
||||||
|
{
|
||||||
$newData['phpgwaccountexpires'] = $this->data['expires'];
|
$newData['phpgwaccountexpires'] = $this->data['expires'];
|
||||||
|
}
|
||||||
|
|
||||||
$newAccountID = $newData['uid'];
|
$newAccountID = $newData['uid'];
|
||||||
$oldAccountID = $newData['uid'];
|
$oldAccountID = $newData['uid'];
|
||||||
@ -163,15 +189,16 @@
|
|||||||
// data for posixgroup
|
// data for posixgroup
|
||||||
$newData['cn'] = $GLOBALS['phpgw']->translation->convert(
|
$newData['cn'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
$this->data['account_lid'],
|
$this->data['account_lid'],
|
||||||
$GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
$GLOBALS['phpgw']->translation->charset(), 'utf-8'
|
||||||
|
);
|
||||||
$newData['gidnumber'] = $this->data['account_id'];
|
$newData['gidnumber'] = $this->data['account_id'];
|
||||||
$newGroupID = $newData['cn'];
|
$newGroupID = $newData['cn'];
|
||||||
$oldGroupID = $newData['cn'];
|
$oldGroupID = $newData['cn'];
|
||||||
}
|
}
|
||||||
if($this->data['type'])
|
if($this->data['type'])
|
||||||
|
{
|
||||||
$newData['phpgwaccounttype'] = $this->data['type'];
|
$newData['phpgwaccounttype'] = $this->data['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Changing the uid: Need to delete and add new, since
|
Changing the uid: Need to delete and add new, since
|
||||||
@ -185,7 +212,7 @@
|
|||||||
{
|
{
|
||||||
$test = $allValues[0]['uid'][0];
|
$test = $allValues[0]['uid'][0];
|
||||||
}
|
}
|
||||||
if ($GLOBALS['phpgw']->translation->convert($test,'utf-8') != $this->data['account_lid'])
|
if($GLOBALS['phpgw']->translation->convert($test,'utf-8') != $this->data['account_lid'])
|
||||||
{
|
{
|
||||||
$oldData = $allValues[0];
|
$oldData = $allValues[0];
|
||||||
$oldDN = $oldData['dn'];
|
$oldDN = $oldData['dn'];
|
||||||
@ -220,15 +247,15 @@
|
|||||||
$newData = array_merge($oldData, $newData);
|
$newData = array_merge($oldData, $newData);
|
||||||
|
|
||||||
/* Groups */
|
/* Groups */
|
||||||
if ($this->data['account_type'] == 'g' && $this->group_context )
|
if($this->data['account_type'] == 'g' && $this->group_context )
|
||||||
{
|
{
|
||||||
$newDN = 'cn='.$this->data['account_lid'].','.$this->group_context;
|
$newDN = 'cn='.$this->data['account_lid'].','.$this->group_context;
|
||||||
$members = $this->member($this->data['account_id']);
|
$members = $this->member($this->data['account_id']);
|
||||||
$newData['memberuid'] = array();
|
$newData['memberuid'] = array();
|
||||||
for ($i=0;$i<count($members);$i++)
|
for($i=0;$i<count($members);$i++)
|
||||||
{
|
{
|
||||||
$currname = $this->id2name($members[$i]['account_id']);
|
$currname = $this->id2name($members[$i]['account_id']);
|
||||||
if (!$this->isin_array($currname,$entry['memberuid']))
|
if(!$this->isin_array($currname,$entry['memberuid']))
|
||||||
{
|
{
|
||||||
$newData['memberuid'][] = $currname;
|
$newData['memberuid'][] = $currname;
|
||||||
}
|
}
|
||||||
@ -251,15 +278,15 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// add the list group members
|
// add the list group members
|
||||||
if ($this->data['account_type'] == 'g' && $this->group_context )
|
if($this->data['account_type'] == 'g' && $this->group_context )
|
||||||
{
|
{
|
||||||
$members = $this->member($this->data['account_id']);
|
$members = $this->member($this->data['account_id']);
|
||||||
#_debug_array($members);
|
#_debug_array($members);
|
||||||
$newData['memberuid'] = array();
|
$newData['memberuid'] = array();
|
||||||
for ($i=0;$i<count($members);$i++)
|
for($i=0;$i<count($members);$i++)
|
||||||
{
|
{
|
||||||
$currname = $this->id2name($members[$i]['account_id']);
|
$currname = $this->id2name($members[$i]['account_id']);
|
||||||
if (!$this->isin_array($currname,$newData['memberuid']))
|
if(!$this->isin_array($currname,$newData['memberuid']))
|
||||||
{
|
{
|
||||||
$newData['memberuid'][] = $currname;
|
$newData['memberuid'][] = $currname;
|
||||||
}
|
}
|
||||||
@ -267,7 +294,6 @@
|
|||||||
}
|
}
|
||||||
// modify the DN
|
// modify the DN
|
||||||
ldap_modify($this->ds, $allValues[0]['dn'], $newData);
|
ldap_modify($this->ds, $allValues[0]['dn'], $newData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->data['account_type'] == 'u')
|
if ($this->data['account_type'] == 'u')
|
||||||
@ -276,7 +302,7 @@
|
|||||||
|
|
||||||
// first lets search for the groups, the user is currently member of
|
// first lets search for the groups, the user is currently member of
|
||||||
// and from which he needs to be removed
|
// and from which he needs to be removed
|
||||||
$filter = "(&(objectclass=posixgroup)(memberuid=$oldAccountID))";
|
$filter = "(&(objectclass=posixgroup)(memberuid=" . (int)$oldAccountID . "))";
|
||||||
$justThese = array('memberuid','gidnumber');
|
$justThese = array('memberuid','gidnumber');
|
||||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||||
if($sri)
|
if($sri)
|
||||||
@ -302,7 +328,6 @@
|
|||||||
$newData['memberuid'] = array_values(sort(array_flip($newData['memberuid'])));
|
$newData['memberuid'] = array_values(sort(array_flip($newData['memberuid'])));
|
||||||
ldap_mod_replace($this->ds, $dn, $newData);
|
ldap_mod_replace($this->ds, $dn, $newData);
|
||||||
#print ldap_error($this->ds);
|
#print ldap_error($this->ds);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -328,7 +353,7 @@
|
|||||||
foreach($this->data['account_groups'] as $key => $value)
|
foreach($this->data['account_groups'] as $key => $value)
|
||||||
{
|
{
|
||||||
// search for the group
|
// search for the group
|
||||||
$filter = 'gidnumber='.$value;
|
$filter = 'gidnumber=' . (int)$value;
|
||||||
$justThese = array('memberuid');
|
$justThese = array('memberuid');
|
||||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||||
if($sri)
|
if($sri)
|
||||||
@ -375,9 +400,9 @@
|
|||||||
function delete($accountid = '')
|
function delete($accountid = '')
|
||||||
{
|
{
|
||||||
$account_id = get_account_id($accountid);
|
$account_id = get_account_id($accountid);
|
||||||
$account_lid = $this->id2name($account_id);
|
$account_lid = $this->id2name((int)$account_id);
|
||||||
|
|
||||||
$filter = 'gidnumber='.$account_id;
|
$filter = 'gidnumber=' . (int)$account_id;
|
||||||
$sri = ldap_search($this->ds, $this->group_context, $filter);
|
$sri = ldap_search($this->ds, $this->group_context, $filter);
|
||||||
if($sri)
|
if($sri)
|
||||||
{
|
{
|
||||||
@ -386,7 +411,7 @@
|
|||||||
|
|
||||||
if(!$allValues[0]['dn'])
|
if(!$allValues[0]['dn'])
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->user_context, 'uid='.$account_lid);
|
$sri = ldap_search($this->ds, $this->user_context, 'uid=' . (string)$account_lid);
|
||||||
if($sri)
|
if($sri)
|
||||||
{
|
{
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
@ -403,7 +428,7 @@
|
|||||||
if($wasAccount)
|
if($wasAccount)
|
||||||
{
|
{
|
||||||
// remove the user from any group he is member of
|
// remove the user from any group he is member of
|
||||||
$filter = "(&(objectclass=posixgroup)(memberuid=$accountID))";
|
$filter = "(&(objectclass=posixgroup)(memberuid=" . (int)$accountID . "))";
|
||||||
$justThese = array('memberuid','gidnumber');
|
$justThese = array('memberuid','gidnumber');
|
||||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||||
if($sri)
|
if($sri)
|
||||||
@ -433,21 +458,21 @@
|
|||||||
{
|
{
|
||||||
//print "\$_type=$_type, \$start=$start , \$sort=$sort, \$order=$order, \$query=$query, \$offset=$offset<br>";
|
//print "\$_type=$_type, \$start=$start , \$sort=$sort, \$order=$order, \$query=$query, \$offset=$offset<br>";
|
||||||
$query = strtolower($query);
|
$query = strtolower($query);
|
||||||
if ($offset)
|
if($offset)
|
||||||
{
|
{
|
||||||
$limitclause = '';//$phpgw->db->limit($start,$offset);
|
$limitclause = '';//$phpgw->db->limit($start,$offset);
|
||||||
}
|
}
|
||||||
elseif ($start && !$offset)
|
elseif($start && !$offset)
|
||||||
{
|
{
|
||||||
$limitclause = '';//$phpgw->db->limit($start);
|
$limitclause = '';//$phpgw->db->limit($start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $sort)
|
if(!$sort)
|
||||||
{
|
{
|
||||||
$sort = '';//"desc";
|
$sort = '';//"desc";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_type == 'accounts')
|
if($_type == 'accounts')
|
||||||
{
|
{
|
||||||
if(empty($query) || $query == "*")
|
if(empty($query) || $query == "*")
|
||||||
{
|
{
|
||||||
@ -478,9 +503,9 @@
|
|||||||
}
|
}
|
||||||
elseif ($_type == 'groups')
|
elseif ($_type == 'groups')
|
||||||
{
|
{
|
||||||
if(empty($query) || $query == "*")
|
if(empty($query) || $query == '*')
|
||||||
{
|
{
|
||||||
$filter = "(&(gidnumber=*)(phpgwaccounttype=g))";
|
$filter = '(&(gidnumber=*)(phpgwaccounttype=g))';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -583,7 +608,13 @@
|
|||||||
return $name_list[$account_lid];
|
return $name_list[$account_lid];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sri = ldap_search($this->ds, $this->group_context, "(&(cn=$account_lid)(phpgwaccounttype=g))");
|
/* Don't bother searching for empty account_lid */
|
||||||
|
if(empty($account_lid))
|
||||||
|
{
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . (string)$account_lid . ')(phpgwaccounttype=g))');
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
if (@$allValues[0]['gidnumber'][0])
|
if (@$allValues[0]['gidnumber'][0])
|
||||||
@ -591,7 +622,7 @@
|
|||||||
$name_list[$account_lid] = (int)$allValues[0]['gidnumber'][0];
|
$name_list[$account_lid] = (int)$allValues[0]['gidnumber'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sri = ldap_search($this->ds, $this->user_context, "(&(uid=$account_lid)(phpgwaccounttype=u))");
|
$sri = ldap_search($this->ds, $this->user_context, '(&(uid=' . (string)$account_lid . ')(phpgwaccounttype=u))');
|
||||||
|
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
@ -613,7 +644,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$allValues = array();
|
$allValues = array();
|
||||||
$sri = ldap_search($this->ds, $this->group_context, "(&(gidnumber=$account_id)(phpgwaccounttype=g))");
|
$sri = ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))');
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
if (@$allValues[0]['cn'][0])
|
if (@$allValues[0]['cn'][0])
|
||||||
@ -623,7 +654,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$allValues = array();
|
$allValues = array();
|
||||||
$sri = ldap_search($this->ds, $this->user_context, "(&(uidnumber=$account_id)(phpgwaccounttype=u))");
|
$sri = ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))');
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
if (@$allValues[0]['uid'][0])
|
if (@$allValues[0]['uid'][0])
|
||||||
@ -650,7 +681,7 @@
|
|||||||
return $account_type[$account_id];
|
return $account_type[$account_id];
|
||||||
}
|
}
|
||||||
$allValues = array();
|
$allValues = array();
|
||||||
$sri = ldap_search($this->ds, $this->user_context, "(&(uidnumber=$account_id)(phpgwaccounttype=u))");
|
$sri = ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))');
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
if ($allValues[0]['phpgwaccounttype'][0])
|
if ($allValues[0]['phpgwaccounttype'][0])
|
||||||
@ -661,7 +692,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$allValues = array();
|
$allValues = array();
|
||||||
$sri = ldap_search($this->ds, $this->group_context, "(&(gidnumber=$account_id)(phpgwaccounttype=g))");
|
$sri = ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))');
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
if ($allValues[0]['phpgwaccounttype'][0])
|
if ($allValues[0]['phpgwaccounttype'][0])
|
||||||
@ -687,6 +718,7 @@
|
|||||||
{
|
{
|
||||||
$ldapgroup = 'gidnumber';
|
$ldapgroup = 'gidnumber';
|
||||||
$ldapacct = 'uidnumber';
|
$ldapacct = 'uidnumber';
|
||||||
|
$account = (int)$account;
|
||||||
/* If data is cached, use it. */
|
/* If data is cached, use it. */
|
||||||
if(@isset($by_id[$account]) && @$by_id[$account])
|
if(@isset($by_id[$account]) && @$by_id[$account])
|
||||||
{
|
{
|
||||||
@ -753,13 +785,13 @@
|
|||||||
$entry['phpgwaccounttype'] = $account_info['account_type'];
|
$entry['phpgwaccounttype'] = $account_info['account_type'];
|
||||||
$entry['phpgwaccountexpires'] = $account_info['account_expires'];
|
$entry['phpgwaccountexpires'] = $account_info['account_expires'];
|
||||||
|
|
||||||
if ($account_info['account_type'] == 'g')
|
if($account_info['account_type'] == 'g')
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->group_context, 'cn=' . $account_info['account_lid']);
|
$sri = ldap_search($this->ds, $this->group_context, 'cn=' . (string)$account_info['account_lid']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->user_context, 'uid=' . $account_info['account_lid']);
|
$sri = ldap_search($this->ds, $this->user_context, 'uid=' . (string)$account_info['account_lid']);
|
||||||
}
|
}
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
@ -813,7 +845,7 @@
|
|||||||
$tmpentry['objectclass'][1] = 'person';
|
$tmpentry['objectclass'][1] = 'person';
|
||||||
$tmpentry['objectclass'][2] = 'organizationalPerson';
|
$tmpentry['objectclass'][2] = 'organizationalPerson';
|
||||||
$tmpentry['objectclass'][3] = 'inetOrgPerson';
|
$tmpentry['objectclass'][3] = 'inetOrgPerson';
|
||||||
$tmpentry['userpassword'] = $GLOBALS['phpgw']->common->encrypt_password($account_info['account_passwd']);
|
$tmpentry['userpassword'] = $GLOBALS['phpgw']->common->encrypt_password($account_info['account_passwd'],False);
|
||||||
/* $tmpentry['objectclass'][4] = 'account'; Causes problems with some LDAP servers */
|
/* $tmpentry['objectclass'][4] = 'account'; Causes problems with some LDAP servers */
|
||||||
$tmpentry['objectclass'][4] = 'posixAccount';
|
$tmpentry['objectclass'][4] = 'posixAccount';
|
||||||
$tmpentry['objectclass'][5] = 'shadowAccount';
|
$tmpentry['objectclass'][5] = 'shadowAccount';
|
||||||
@ -844,20 +876,30 @@
|
|||||||
{
|
{
|
||||||
$dn = 'uid=' . $account_info['account_lid'] . ',' . $this->user_context;
|
$dn = 'uid=' . $account_info['account_lid'] . ',' . $this->user_context;
|
||||||
|
|
||||||
$entry['cn'] = $GLOBALS['phpgw']->translation->convert(sprintf("%s %s",
|
$entry['cn'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
|
sprintf(
|
||||||
|
"%s %s",
|
||||||
$account_info['account_firstname'],
|
$account_info['account_firstname'],
|
||||||
$account_info['account_lastname']
|
$account_info['account_lastname']
|
||||||
), $GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
),
|
||||||
|
$GLOBALS['phpgw']->translation->charset(),
|
||||||
|
'utf-8'
|
||||||
|
);
|
||||||
|
|
||||||
$entry['sn'] = $GLOBALS['phpgw']->translation->convert(
|
$entry['sn'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
$account_info['account_lastname'],
|
$account_info['account_lastname'],
|
||||||
$GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
$GLOBALS['phpgw']->translation->charset(),
|
||||||
|
'utf-8'
|
||||||
|
);
|
||||||
|
|
||||||
if($account_info['account_firstname'])
|
if($account_info['account_firstname'])
|
||||||
|
{
|
||||||
$entry['givenname'] = $GLOBALS['phpgw']->translation->convert(
|
$entry['givenname'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
$account_info['account_firstname'],
|
$account_info['account_firstname'],
|
||||||
$GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
$GLOBALS['phpgw']->translation->charset(),
|
||||||
|
'utf-8'
|
||||||
|
);
|
||||||
|
}
|
||||||
$entry['uid'] = $account_info['account_lid'];
|
$entry['uid'] = $account_info['account_lid'];
|
||||||
$entry['uidnumber'] = $account_id;
|
$entry['uidnumber'] = $account_id;
|
||||||
$entry['gidnumber'] = $account_info['account_primary_group'];
|
$entry['gidnumber'] = $account_info['account_primary_group'];
|
||||||
@ -870,7 +912,9 @@
|
|||||||
$entry['objectclass'][5] = 'shadowAccount';
|
$entry['objectclass'][5] = 'shadowAccount';
|
||||||
$entry['objectclass'][6] = 'phpgwAccount';
|
$entry['objectclass'][6] = 'phpgwAccount';
|
||||||
if($account_info['account_status'])
|
if($account_info['account_status'])
|
||||||
|
{
|
||||||
$entry['phpgwaccountstatus'] = $account_info['account_status'];
|
$entry['phpgwaccountstatus'] = $account_info['account_status'];
|
||||||
|
}
|
||||||
$entry['phpgwaccounttype'] = $account_info['account_type'];
|
$entry['phpgwaccounttype'] = $account_info['account_type'];
|
||||||
$entry['phpgwaccountexpires'] = $account_info['account_expires'];
|
$entry['phpgwaccountexpires'] = $account_info['account_expires'];
|
||||||
}
|
}
|
||||||
@ -888,10 +932,11 @@
|
|||||||
// lets check group the user needs to be added
|
// lets check group the user needs to be added
|
||||||
if($account_info['account_type'] == 'u')
|
if($account_info['account_type'] == 'u')
|
||||||
{
|
{
|
||||||
|
@settype($account_info['account_groups'],'array');
|
||||||
foreach($account_info['account_groups'] as $key => $value)
|
foreach($account_info['account_groups'] as $key => $value)
|
||||||
{
|
{
|
||||||
// search for the group
|
// search for the group
|
||||||
$filter = 'gidnumber='.$value;
|
$filter = 'gidnumber=' . (int)$value;
|
||||||
$justThese = array('memberuid');
|
$justThese = array('memberuid');
|
||||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||||
if($sri)
|
if($sri)
|
||||||
@ -956,7 +1001,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* expire in 30 days by default */
|
/* expire in 30 days by default */
|
||||||
$expiredate = time() + ( ( 60 * 60 ) * (30 * 24) );
|
$expiredate = time() + ((60 * 60) * (30 * 24));
|
||||||
$expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate));
|
$expires = mktime(2,0,0,date('n',$expiredate), (int)date('d',$expiredate), date('Y',$expiredate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -991,10 +1036,10 @@
|
|||||||
$defaultgroupid = $default_group_id ? $default_group_id : $this->name2id('Default');
|
$defaultgroupid = $default_group_id ? $default_group_id : $this->name2id('Default');
|
||||||
if($defaultgroupid)
|
if($defaultgroupid)
|
||||||
{
|
{
|
||||||
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', "
|
$this->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES('phpgw_group', "
|
||||||
. $defaultgroupid . ", " . $accountid . ", 1)",__LINE__,__FILE__);
|
. $defaultgroupid . ", " . $accountid . ", 1)",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)values('preferences', 'changepassword', ".$accountid.", 1)",__LINE__,__FILE__);
|
$this->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)VALUES('preferences', 'changepassword', ".$accountid.", 1)",__LINE__,__FILE__);
|
||||||
@reset($apps);
|
@reset($apps);
|
||||||
while(list($key,$app) = each($apps))
|
while(list($key,$app) = each($apps))
|
||||||
{
|
{
|
||||||
@ -1020,13 +1065,13 @@
|
|||||||
$acct_type = $this->get_type($account_id);
|
$acct_type = $this->get_type($account_id);
|
||||||
|
|
||||||
/* search the dn for the given uid */
|
/* search the dn for the given uid */
|
||||||
if ( ($acct_type == 'g') && $this->group_context )
|
if(($acct_type == 'g') && $this->group_context)
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber='.$account_id);
|
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber=' . (int)$account_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber='.$account_id);
|
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$account_id);
|
||||||
}
|
}
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
@ -1066,7 +1111,7 @@
|
|||||||
{
|
{
|
||||||
$_account_id = get_account_id($_accountid);
|
$_account_id = get_account_id($_accountid);
|
||||||
|
|
||||||
$sri = ldap_search($this->ds, $this->user_context, "uidnumber=$_account_id");
|
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$_account_id);
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
return $allValues[0]['dn'];
|
return $allValues[0]['dn'];
|
||||||
|
Loading…
Reference in New Issue
Block a user