mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
ldap fixes
This commit is contained in:
parent
90331f1b45
commit
2a4b75c483
@ -853,60 +853,67 @@
|
||||
$entry['objectclass'][4] = 'posixAccount';
|
||||
$entry['objectclass'][5] = 'shadowAccount';
|
||||
$entry['objectclass'][6] = 'phpgwAccount';
|
||||
$entry['phpgwaccountstatus'] = $account_info['account_status'];
|
||||
if($account_info['account_status'])
|
||||
$entry['phpgwaccountstatus'] = $account_info['account_status'];
|
||||
$entry['phpgwaccounttype'] = $account_info['account_type'];
|
||||
$entry['phpgwaccountexpires'] = $account_info['account_expires'];
|
||||
}
|
||||
|
||||
#_debug_array($entry);
|
||||
|
||||
ldap_add($this->ds, $dn, $entry);
|
||||
// stop processing if ldap_add fails
|
||||
if(!ldap_add($this->ds, $dn, $entry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// print ldap_error($this->ds);
|
||||
|
||||
// lets check group the user needs to be added
|
||||
if($account_info['account_type'] == 'u')
|
||||
{
|
||||
foreach($account_info['account_groups'] as $key => $value)
|
||||
{
|
||||
// search for the group
|
||||
$filter = 'gidnumber='.$value;
|
||||
$justThese = array('memberuid');
|
||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||
if($sri)
|
||||
foreach($account_info['account_groups'] as $key => $value)
|
||||
{
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
// if the user is not member of this group, add him
|
||||
if(is_array($allValues[0]['memberuid']))
|
||||
// search for the group
|
||||
$filter = 'gidnumber='.$value;
|
||||
$justThese = array('memberuid');
|
||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||
if($sri)
|
||||
{
|
||||
// this group has already some members
|
||||
if(!in_array($account_info['account_lid'],$allValues[0]['memberuid']))
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
// if the user is not member of this group, add him
|
||||
if(is_array($allValues[0]['memberuid']))
|
||||
{
|
||||
// this group has already some members
|
||||
if(!in_array($account_info['account_lid'],$allValues[0]['memberuid']))
|
||||
{
|
||||
$dn = $allValues[0]['dn'];
|
||||
$newData = array();
|
||||
$newData['memberuid'] = $allValues[0]['memberuid'];
|
||||
unset($newData['memberuid']['count']);
|
||||
$newData['memberuid'][] = $account_info['account_lid'];
|
||||
$newData['memberuid'] = array_unique($newData['memberuid']);
|
||||
ldap_mod_replace($this->ds, $dn, $newData);
|
||||
#print ldap_error($this->ds)."<br>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// this group has no members
|
||||
$dn = $allValues[0]['dn'];
|
||||
$newData = array();
|
||||
$newData['memberuid'] = $allValues[0]['memberuid'];
|
||||
unset($newData['memberuid']['count']);
|
||||
$newData['memberuid'][] = $account_info['account_lid'];
|
||||
$newData['memberuid'] = array_unique($newData['memberuid']);
|
||||
$newData['memberuid'][] = $account_info['account_lid'];
|
||||
ldap_mod_replace($this->ds, $dn, $newData);
|
||||
#print ldap_error($this->ds)."<br>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// this group has no members
|
||||
$dn = $allValues[0]['dn'];
|
||||
$newData = array();
|
||||
$newData['memberuid'][] = $account_info['account_lid'];
|
||||
ldap_mod_replace($this->ds, $dn, $newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($account_id && is_object($GLOBALS['phpgw']->preferences) && $default_prefs)
|
||||
{
|
||||
$GLOBALS['phpgw']->preferences->create_defaults($account_id);
|
||||
}
|
||||
|
||||
return $account_id;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare API - Auth from LDAP *
|
||||
* This file written by Lars Kneschke <kneschke@phpgroupware.org> *
|
||||
* This file written by Lars Kneschke <lkneschke@linux-at-work.de> *
|
||||
* and Joseph Engo <jengo@phpgroupware.org> *
|
||||
* Authentication based on LDAP Server *
|
||||
* Copyright (C) 2000, 2001 Joseph Engo *
|
||||
* Copyright (C) 2002, 2003 Lars Kneschke *
|
||||
* -------------------------------------------------------------------------*
|
||||
* This library is part of the phpGroupWare API *
|
||||
* http://www.phpgroupware.org/api *
|
||||
@ -54,8 +55,9 @@
|
||||
return False;
|
||||
}
|
||||
/* find the dn for this uid, the uid is not always in the dn */
|
||||
$attributes = array( "uid", "dn" );
|
||||
$sri = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], "(uid=$username)", $attributes);
|
||||
$attributes = array( "uid", "dn" );
|
||||
$filter = "(&(uid=$username)(phpgwaccountstatus=A))";
|
||||
$sri = ldap_search($ldap, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $attributes);
|
||||
$allValues = ldap_get_entries($ldap, $sri);
|
||||
if ($allValues['count'] > 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user