implemented account building for file uploads

This commit is contained in:
Roland Gruber 2004-09-27 19:14:16 +00:00
parent 915135b3ce
commit 8ac15ce411
1 changed files with 55 additions and 1 deletions

View File

@ -24,7 +24,7 @@ $Id$
class sambaGroupMapping extends baseModule { class sambaGroupMapping extends baseModule {
// Variables // Variables
// Array of well known rids /** Array of well known RIDs */
var $rids; var $rids;
@ -50,6 +50,60 @@ class sambaGroupMapping extends baseModule {
parent::baseModule($scope); parent::baseModule($scope);
} }
/**
* In this function the LDAP account is built up.
*
* @param array $rawAccounts list of hash arrays (name => value) from user input
* @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP
* @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5)
* @return array list of error messages if any
*/
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
// search existing Samba 3 domains
$domains = search_domains($_SESSION['config']->get_domainSuffix());
$nameToSID = array();
// get domain SIDs
for ($i = 0; $i < sizeof($domains); $i++) {
$nameToSID[$domains[$i]->name] = $domains[$i]->SID;
}
// get domain RID bases
$nameToRIDBase = array();
for ($i = 0; $i < sizeof($domains); $i++) {
$nameToRIDBase[$domains[$i]->name] = $domains[$i]->RIDbase;
}
$errors = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// group type is always 2
$partialAccounts[$i]['sambaGroupType'] = "2";
if (!in_array("sambaGroupMapping", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "sambaGroupMapping";
// SID
$domSID = $nameToSID[$rawAccounts[$i][$ids['sambaGroupMapping_domain']]];
if (!isset($domSID)) {
$errors[] =array("ERROR", "", ""); // TODO
}
else {
// RID
$rid = $rawAccounts[$i][$ids['sambaGroupMapping_rid']];
if (isset($this->rids[$rid])) $rid = $this->rids[$rid];
// check if RID has to be calculated
if (($rid == "") || (!isset($rid))) {
$ridBase = $nameToRIDBase[$rawAccounts[$i][$ids['sambaGroupMapping_domain']]];
$partialAccounts[$i]['sambaSID'] = $domSID . "-" . (($partialAccounts[$i]['gidNumber'] * 2) + $ridBase + 1);
}
elseif (get_preg($rid, 'digit')) {
$partialAccounts[$i]['sambaSID'] = $domSID . "-" . $rid;
}
}
// display name (UTF-8, no regex check needed)
if ($rawAccounts[$i][$ids['sambaGroupMapping_name']] == "") {
$partialAccounts[$i]['displayName'] = $partialAccounts[$i]['cn'];
}
else {
$partialAccounts[$i]['displayName'] = $rawAccounts[$i][$ids['sambaGroupMapping_name']];
}
}
}
function delete_attributes($post) { function delete_attributes($post) {
return 0; return 0;
} }