mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +01:00
eabf6925b5
but reduced to those functions, which are needed to manage ldap entries, which rely only on standard schemas (core, qmail) which are not considered "experimental" and without the need to add a separate schema. This modul will be extended whenever possible and approved for more values. Main goal here is: Ability to easily use eGW Admin for account management with LDAP beackend and to comply with those schemas, the distros are delivering. The link for this module will be shown in addition to Lars' EmailAdmin if LDAP is used as account storage. So it will not break existing installation ;-)
174 lines
4.9 KiB
PHP
174 lines
4.9 KiB
PHP
<?php
|
|
/***************************************************************************\
|
|
* EGroupWare - LDAPManager *
|
|
* http://www.egroupware.org *
|
|
* Written by : Andreas Krause (ak703@users.sourceforge.net *
|
|
* based on EmailAdmin by Lars Kneschke [lkneschke@egroupware.org] *
|
|
* ------------------------------------------------- *
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
* under the terms of the GNU General Public License as published by the *
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
* option) any later version. *
|
|
\***************************************************************************/
|
|
|
|
class soldap_mgr
|
|
{
|
|
function soldap_mgr()
|
|
{
|
|
$this->db = $GLOBALS['phpgw']->db;
|
|
include(PHPGW_INCLUDE_ROOT.'/emailadmin/setup/tables_current.inc.php');
|
|
$this->tables = &$phpgw_baseline;
|
|
unset($phpgw_baseline);
|
|
$this->table = &$this->tables['phpgw_emailadmin'];
|
|
}
|
|
|
|
|
|
function getUserData($_accountID)
|
|
{
|
|
global $phpgw, $phpgw_info;
|
|
|
|
$ldap = $phpgw->common->ldapConnect();
|
|
$filter = "(&(uidnumber=$_accountID))";
|
|
|
|
$sri = @ldap_search($ldap,$phpgw_info['server']['ldap_context'],$filter);
|
|
if ($sri)
|
|
{
|
|
$allValues = ldap_get_entries($ldap, $sri);
|
|
if ($allValues['count'] > 0)
|
|
{
|
|
#print "found something<br>";
|
|
$userData["mail"] = $allValues[0]["mail"][0];
|
|
$userData["mailAlternateAddress"] = $allValues[0]["mailalternateaddress"];
|
|
$userData["accountStatus"] = $allValues[0]["accountstatus"][0];
|
|
$userData["mailForwardingAddress"] = $allValues[0]["mailforwardingaddress"][0];
|
|
$userData["deliveryMode"] = $allValues[0]["deliverymode"][0];
|
|
|
|
unset($userData["mailAlternateAddress"]["count"]);
|
|
unset($userData["mailForwardingAddress"]["count"]);
|
|
|
|
return $userData;
|
|
}
|
|
}
|
|
|
|
// if we did not return before, return false
|
|
return false;
|
|
}
|
|
|
|
function saveUserData($_accountID, $_accountData)
|
|
{
|
|
|
|
$ldap = $GLOBALS['phpgw']->common->ldapConnect();
|
|
// need to be fixed
|
|
if(is_numeric($_accountID))
|
|
{
|
|
$filter = "uidnumber=$_accountID";
|
|
}
|
|
else
|
|
{
|
|
$filter = "uid=$_accountID";
|
|
}
|
|
|
|
$sri = @ldap_search($ldap,$GLOBALS['phpgw_info']['server']['ldap_context'],$filter);
|
|
if ($sri)
|
|
{
|
|
$allValues = ldap_get_entries($ldap, $sri);
|
|
$accountDN = $allValues[0]['dn'];
|
|
$uid = $allValues[0]['uid'][0];
|
|
$homedirectory = $allValues[0]['homedirectory'][0];
|
|
$objectClasses = $allValues[0]['objectclass'];
|
|
|
|
unset($objectClasses['count']);
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if(empty($homedirectory))
|
|
{
|
|
$homedirectory = "/home/".$uid;
|
|
}
|
|
|
|
// the old code for qmail ldap
|
|
$newData = array
|
|
(
|
|
'mail' => $_accountData["mail"],
|
|
'mailAlternateAddress' => $_accountData["mailAlternateAddress"],
|
|
'mailForwardingAddress' => $_accountData["mailForwardingAddress"],
|
|
// 'homedirectory' => $homedirectory,
|
|
// 'mailMessageStore' => $homedirectory."/Maildir/",
|
|
// 'gidnumber' => '1000',
|
|
// 'qmailDotMode' => $_accountData["qmailDotMode"],
|
|
// 'deliveryProgramPath' => $_accountData["deliveryProgramPath"]
|
|
);
|
|
|
|
if(!in_array('qmailUser',$objectClasses) &&
|
|
!in_array('qmailuser',$objectClasses))
|
|
{
|
|
$objectClasses[] = 'qmailuser';
|
|
}
|
|
|
|
// the new code for postfix+cyrus+ldap
|
|
$newData = array
|
|
(
|
|
'mail' => $_accountData["mail"],
|
|
'accountStatus' => $_accountData["accountStatus"],
|
|
'objectclass' => $objectClasses
|
|
);
|
|
|
|
if(is_array($_accountData["mailAlternateAddress"]))
|
|
{
|
|
$newData['mailAlternateAddress'] = $_accountData["mailAlternateAddress"];
|
|
}
|
|
else
|
|
{
|
|
$newData['mailAlternateAddress'] = array();
|
|
}
|
|
|
|
if($_accountData["accountStatus"] == 'active')
|
|
{
|
|
$newData['accountStatus'] = 'active';
|
|
}
|
|
else
|
|
{
|
|
$newData['accountStatus'] = 'disabled';
|
|
}
|
|
/*
|
|
if(!empty($_accountData["deliveryMode"]))
|
|
{
|
|
$newData['deliveryMode'] = $_accountData["deliveryMode"];
|
|
}
|
|
else
|
|
{
|
|
$newData['deliveryMode'] = array();
|
|
}
|
|
*/
|
|
|
|
// if(is_array($_accountData["mailForwardingAddress"]))
|
|
// {
|
|
$newData['mailForwardingAddress'] = $_accountData["mailForwardingAddress"];
|
|
// }
|
|
// else
|
|
// {
|
|
// $newData['mailForwardingAddress'] = array();
|
|
// }
|
|
|
|
#print "<br>DN: $accountDN<br>";
|
|
ldap_mod_replace ($ldap, $accountDN, $newData);
|
|
|
|
// also update the account_email field in phpgw_accounts
|
|
// when using sql account storage
|
|
if($GLOBALS['phpgw_info']['server']['account_repository'] == 'sql')
|
|
{
|
|
$this->db->update('phpgw_accounts',array(
|
|
'account_email' => $_accountData["mail"]
|
|
),
|
|
array(
|
|
'account_id' => $_accountID
|
|
),__LINE__,__FILE__
|
|
);
|
|
}
|
|
}
|
|
}
|
|
?>
|