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