performance fixes
This commit is contained in:
parent
169cb977f0
commit
463548c948
|
@ -495,7 +495,9 @@ function buildUploadAccounts($scope, $data, $ids, $selectedModules) {
|
||||||
// give raw data to modules
|
// give raw data to modules
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$partialAccounts = array();
|
$partialAccounts = array();
|
||||||
for ($i = 0; $i < sizeof($data); $i++) $partialAccounts[$i]['objectClass'] = array();
|
foreach ($data as $i => $dataRow) {
|
||||||
|
$partialAccounts[$i]['objectClass'] = array();
|
||||||
|
}
|
||||||
for ($i = 0; $i < sizeof($ordered); $i++) {
|
for ($i = 0; $i < sizeof($ordered); $i++) {
|
||||||
$module = new $ordered[$i]($scope);
|
$module = new $ordered[$i]($scope);
|
||||||
$errors = $module->build_uploadAccounts($data, $ids, $partialAccounts, $selectedModules);
|
$errors = $module->build_uploadAccounts($data, $ids, $partialAccounts, $selectedModules);
|
||||||
|
|
|
@ -1984,18 +1984,18 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check input
|
// check input
|
||||||
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
|
foreach ($rawAccounts as $i => $rawAccount) {
|
||||||
if (!in_array("posixAccount", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixAccount";
|
if (!in_array("posixAccount", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixAccount";
|
||||||
// UID
|
// UID
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_uid']] == "") {
|
if ($rawAccount[$ids['posixAccount_uid']] == "") {
|
||||||
// autoUID
|
// autoUID
|
||||||
$needAutoUID[] = $i;
|
$needAutoUID[] = $i;
|
||||||
}
|
}
|
||||||
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_uid']], 'digit')) {
|
elseif (get_preg($rawAccount[$ids['posixAccount_uid']], 'digit')) {
|
||||||
if ($this->get_scope() == 'user') {
|
if ($this->get_scope() == 'user') {
|
||||||
if (($rawAccounts[$i][$ids['posixAccount_uid']] > $this->moduleSettings['posixAccount_minUID'][0]) &&
|
if (($rawAccount[$ids['posixAccount_uid']] > $this->moduleSettings['posixAccount_minUID'][0]) &&
|
||||||
($rawAccounts[$i][$ids['posixAccount_uid']] < $this->moduleSettings['posixAccount_maxUID'][0])) {
|
($rawAccount[$ids['posixAccount_uid']] < $this->moduleSettings['posixAccount_maxUID'][0])) {
|
||||||
$partialAccounts[$i]['uidNumber'] = trim($rawAccounts[$i][$ids['posixAccount_uid']]);
|
$partialAccounts[$i]['uidNumber'] = trim($rawAccount[$ids['posixAccount_uid']]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uidNumber'][4];
|
$errMsg = $this->messages['uidNumber'][4];
|
||||||
|
@ -2004,9 +2004,9 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($this->get_scope() == 'host') {
|
elseif ($this->get_scope() == 'host') {
|
||||||
if (($rawAccounts[$i][$ids['posixAccount_uid']] > $this->moduleSettings['posixAccount_minMachine'][0]) &&
|
if (($rawAccount[$ids['posixAccount_uid']] > $this->moduleSettings['posixAccount_minMachine'][0]) &&
|
||||||
($rawAccounts[$i][$ids['posixAccount_uid']] < $this->moduleSettings['posixAccount_maxMachine'][0])) {
|
($rawAccount[$ids['posixAccount_uid']] < $this->moduleSettings['posixAccount_maxMachine'][0])) {
|
||||||
$partialAccounts[$i]['uidNumber'] = trim($rawAccounts[$i][$ids['posixAccount_uid']]);
|
$partialAccounts[$i]['uidNumber'] = trim($rawAccount[$ids['posixAccount_uid']]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uidNumber'][4];
|
$errMsg = $this->messages['uidNumber'][4];
|
||||||
|
@ -2021,11 +2021,11 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$errors[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// GID number
|
// GID number
|
||||||
if (get_preg($rawAccounts[$i][$ids['posixAccount_group']], 'digit')) {
|
if (get_preg($rawAccount[$ids['posixAccount_group']], 'digit')) {
|
||||||
$partialAccounts[$i]['gidNumber'] = $rawAccounts[$i][$ids['posixAccount_group']];
|
$partialAccounts[$i]['gidNumber'] = $rawAccount[$ids['posixAccount_group']];
|
||||||
}
|
}
|
||||||
if (get_preg($rawAccounts[$i][$ids['posixAccount_group']], 'groupname')) {
|
if (get_preg($rawAccount[$ids['posixAccount_group']], 'groupname')) {
|
||||||
$gid = $groupMap[$rawAccounts[$i][$ids['posixAccount_group']]];
|
$gid = $groupMap[$rawAccount[$ids['posixAccount_group']]];
|
||||||
if (is_numeric($gid)) {
|
if (is_numeric($gid)) {
|
||||||
$partialAccounts[$i]['gidNumber'] = $gid;
|
$partialAccounts[$i]['gidNumber'] = $gid;
|
||||||
}
|
}
|
||||||
|
@ -2042,9 +2042,9 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
// GECOS
|
// GECOS
|
||||||
if (!$this->isBooleanConfigOptionSet('posixAccount_hidegecos')) {
|
if (!$this->isBooleanConfigOptionSet('posixAccount_hidegecos')) {
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_gecos']] != "") {
|
if ($rawAccount[$ids['posixAccount_gecos']] != "") {
|
||||||
if (get_preg($rawAccounts[$i][$ids['posixAccount_gecos']], 'gecos')) {
|
if (get_preg($rawAccount[$ids['posixAccount_gecos']], 'gecos')) {
|
||||||
$partialAccounts[$i]['gecos'] = $this->checkASCII($rawAccounts[$i][$ids['posixAccount_gecos']]);
|
$partialAccounts[$i]['gecos'] = $this->checkASCII($rawAccount[$ids['posixAccount_gecos']]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['gecos'][0];
|
$errMsg = $this->messages['gecos'][0];
|
||||||
|
@ -2054,12 +2054,12 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$gecos = "";
|
$gecos = "";
|
||||||
if (($rawAccounts[$i][$ids['inetOrgPerson_firstName']] != "") && ($rawAccounts[$i][$ids['inetOrgPerson_lastName']] != "")) {
|
if (($rawAccount[$ids['inetOrgPerson_firstName']] != "") && ($rawAccount[$ids['inetOrgPerson_lastName']] != "")) {
|
||||||
$gecos = $rawAccounts[$i][$ids['inetOrgPerson_firstName']] . " " . $rawAccounts[$i][$ids['inetOrgPerson_lastName']];
|
$gecos = $rawAccount[$ids['inetOrgPerson_firstName']] . " " . $rawAccount[$ids['inetOrgPerson_lastName']];
|
||||||
if ($rawAccounts[$i][$ids['inetOrgPerson_telephone']] != "") {
|
if ($rawAccount[$ids['inetOrgPerson_telephone']] != "") {
|
||||||
$gecos = $gecos . ",," . $rawAccounts[$i][$ids['inetOrgPerson_telephone']]; // double "," because room is unknown
|
$gecos = $gecos . ",," . $rawAccount[$ids['inetOrgPerson_telephone']]; // double "," because room is unknown
|
||||||
if ($rawAccounts[$i][$ids['inetOrgPerson_fax']] != "") {
|
if ($rawAccount[$ids['inetOrgPerson_fax']] != "") {
|
||||||
$gecos = $gecos . "," . $rawAccounts[$i][$ids['inetOrgPerson_fax']];
|
$gecos = $gecos . "," . $rawAccount[$ids['inetOrgPerson_fax']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2071,8 +2071,8 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
// user specific attributes
|
// user specific attributes
|
||||||
if ($this->get_scope() == 'user') {
|
if ($this->get_scope() == 'user') {
|
||||||
// additional groups
|
// additional groups
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_additionalGroups']] != "") {
|
if ($rawAccount[$ids['posixAccount_additionalGroups']] != "") {
|
||||||
$groups = explode(",", $rawAccounts[$i][$ids['posixAccount_additionalGroups']]);
|
$groups = explode(",", $rawAccount[$ids['posixAccount_additionalGroups']]);
|
||||||
for ($g = 0; $g < sizeof($groups); $g++) {
|
for ($g = 0; $g < sizeof($groups); $g++) {
|
||||||
if (!in_array($groups[$g], $existingGroups)) {
|
if (!in_array($groups[$g], $existingGroups)) {
|
||||||
$errors[] = array('ERROR', _('Unable to find group in LDAP.'), $groups[$g]);
|
$errors[] = array('ERROR', _('Unable to find group in LDAP.'), $groups[$g]);
|
||||||
|
@ -2080,8 +2080,8 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// group of names
|
// group of names
|
||||||
if (self::areGroupOfNamesActive() && ($rawAccounts[$i][$ids['posixAccount_gon']] != "")) {
|
if (self::areGroupOfNamesActive() && ($rawAccount[$ids['posixAccount_gon']] != "")) {
|
||||||
$groups = explode(",", $rawAccounts[$i][$ids['posixAccount_gon']]);
|
$groups = explode(",", $rawAccount[$ids['posixAccount_gon']]);
|
||||||
for ($g = 0; $g < sizeof($groups); $g++) {
|
for ($g = 0; $g < sizeof($groups); $g++) {
|
||||||
if (!in_array($groups[$g], $gonList)) {
|
if (!in_array($groups[$g], $gonList)) {
|
||||||
$errors[] = array('ERROR', _('Unable to find group in LDAP.'), $groups[$g]);
|
$errors[] = array('ERROR', _('Unable to find group in LDAP.'), $groups[$g]);
|
||||||
|
@ -2089,17 +2089,17 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// user name
|
// user name
|
||||||
if (in_array($rawAccounts[$i][$ids['posixAccount_userName']], $existingUsers)) {
|
if (in_array($rawAccount[$ids['posixAccount_userName']], $existingUsers)) {
|
||||||
$userName = $rawAccounts[$i][$ids['posixAccount_userName']];
|
$userName = $rawAccount[$ids['posixAccount_userName']];
|
||||||
while (in_array($userName, $existingUsers)) {
|
while (in_array($userName, $existingUsers)) {
|
||||||
$userName = $this->getNextUserName($userName);
|
$userName = $this->getNextUserName($userName);
|
||||||
}
|
}
|
||||||
$errMsg = $this->messages['uid'][9];
|
$errMsg = $this->messages['uid'][9];
|
||||||
array_push($errMsg, array($i, $userName, $rawAccounts[$i][$ids['posixAccount_userName']]));
|
array_push($errMsg, array($i, $userName, $rawAccount[$ids['posixAccount_userName']]));
|
||||||
$errors[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_userName']], 'username')) {
|
elseif (get_preg($rawAccount[$ids['posixAccount_userName']], 'username')) {
|
||||||
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_userName']];
|
$partialAccounts[$i]['uid'] = $rawAccount[$ids['posixAccount_userName']];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uid'][7];
|
$errMsg = $this->messages['uid'][7];
|
||||||
|
@ -2107,11 +2107,11 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$errors[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// home directory
|
// home directory
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_homedir']] == "") {
|
if ($rawAccount[$ids['posixAccount_homedir']] == "") {
|
||||||
$partialAccounts[$i][$homedirAttrName] = '/home/' . $partialAccounts[$i]['uid'];
|
$partialAccounts[$i][$homedirAttrName] = '/home/' . $partialAccounts[$i]['uid'];
|
||||||
}
|
}
|
||||||
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_homedir']], 'homeDirectory')) {
|
elseif (get_preg($rawAccount[$ids['posixAccount_homedir']], 'homeDirectory')) {
|
||||||
$partialAccounts[$i][$homedirAttrName] = $rawAccounts[$i][$ids['posixAccount_homedir']];
|
$partialAccounts[$i][$homedirAttrName] = $rawAccount[$ids['posixAccount_homedir']];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['homeDirectory'][2];
|
$errMsg = $this->messages['homeDirectory'][2];
|
||||||
|
@ -2119,11 +2119,11 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$errors[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// login shell
|
// login shell
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_shell']] == "") {
|
if ($rawAccount[$ids['posixAccount_shell']] == "") {
|
||||||
$partialAccounts[$i]['loginShell'] = '/bin/bash';
|
$partialAccounts[$i]['loginShell'] = '/bin/bash';
|
||||||
}
|
}
|
||||||
elseif (in_array($rawAccounts[$i][$ids['posixAccount_shell']], $this->getShells())) {
|
elseif (in_array($rawAccount[$ids['posixAccount_shell']], $this->getShells())) {
|
||||||
$partialAccounts[$i]['loginShell'] = $rawAccounts[$i][$ids['posixAccount_shell']];
|
$partialAccounts[$i]['loginShell'] = $rawAccount[$ids['posixAccount_shell']];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['shell'][0];
|
$errMsg = $this->messages['shell'][0];
|
||||||
|
@ -2132,11 +2132,11 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
$pwd_enabled = true;
|
$pwd_enabled = true;
|
||||||
// password enabled/disabled
|
// password enabled/disabled
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_passwordDisabled']] == "") {
|
if ($rawAccount[$ids['posixAccount_passwordDisabled']] == "") {
|
||||||
$pwd_enabled = true;
|
$pwd_enabled = true;
|
||||||
}
|
}
|
||||||
elseif (in_array($rawAccounts[$i][$ids['posixAccount_passwordDisabled']], array('true', 'false'))) {
|
elseif (in_array($rawAccount[$ids['posixAccount_passwordDisabled']], array('true', 'false'))) {
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_passwordDisabled']] == 'true') $pwd_enabled = false;
|
if ($rawAccount[$ids['posixAccount_passwordDisabled']] == 'true') $pwd_enabled = false;
|
||||||
else $pwd_enabled = true;
|
else $pwd_enabled = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2145,11 +2145,11 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$errors[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// password
|
// password
|
||||||
if (($rawAccounts[$i][$ids['posixAccount_password']] != "") && (get_preg($rawAccounts[$i][$ids['posixAccount_password']], 'password'))) {
|
if (($rawAccount[$ids['posixAccount_password']] != "") && (get_preg($rawAccount[$ids['posixAccount_password']], 'password'))) {
|
||||||
$partialAccounts[$i][$pwdAttrName] = pwd_hash($rawAccounts[$i][$ids['posixAccount_password']], $pwd_enabled, $this->moduleSettings['posixAccount_pwdHash'][0]);
|
$partialAccounts[$i][$pwdAttrName] = pwd_hash($rawAccount[$ids['posixAccount_password']], $pwd_enabled, $this->moduleSettings['posixAccount_pwdHash'][0]);
|
||||||
$partialAccounts[$i]['INFO.userPasswordClearText'] = $rawAccounts[$i][$ids['posixAccount_password']]; // for custom scripts etc.
|
$partialAccounts[$i]['INFO.userPasswordClearText'] = $rawAccount[$ids['posixAccount_password']]; // for custom scripts etc.
|
||||||
}
|
}
|
||||||
elseif ($rawAccounts[$i][$ids['posixAccount_password']] != "") {
|
elseif ($rawAccount[$ids['posixAccount_password']] != "") {
|
||||||
$errMsg = $this->messages['userPassword'][4];
|
$errMsg = $this->messages['userPassword'][4];
|
||||||
$errMsg[2] = str_replace('%', '%%', $errMsg[2]); // double "%" because of later sprintf
|
$errMsg[2] = str_replace('%', '%%', $errMsg[2]); // double "%" because of later sprintf
|
||||||
array_push($errMsg, array($i));
|
array_push($errMsg, array($i));
|
||||||
|
@ -2157,9 +2157,9 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
// cn
|
// cn
|
||||||
if ($this->manageCn()) {
|
if ($this->manageCn()) {
|
||||||
if ($rawAccounts[$i][$ids['posixAccount_cn']] != "") {
|
if ($rawAccount[$ids['posixAccount_cn']] != "") {
|
||||||
if (get_preg($rawAccounts[$i][$ids['posixAccount_cn']], 'cn')) {
|
if (get_preg($rawAccount[$ids['posixAccount_cn']], 'cn')) {
|
||||||
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixAccount_cn']];
|
$partialAccounts[$i]['cn'] = $rawAccount[$ids['posixAccount_cn']];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['cn'][1];
|
$errMsg = $this->messages['cn'][1];
|
||||||
|
@ -2183,18 +2183,18 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
// host specific attributes
|
// host specific attributes
|
||||||
elseif ($this->get_scope() == 'host') {
|
elseif ($this->get_scope() == 'host') {
|
||||||
// host name
|
// host name
|
||||||
if (in_array($rawAccounts[$i][$ids['posixAccount_hostName']], $existingUsers)) {
|
if (in_array($rawAccount[$ids['posixAccount_hostName']], $existingUsers)) {
|
||||||
$userName = $rawAccounts[$i][$ids['posixAccount_hostName']];
|
$userName = $rawAccount[$ids['posixAccount_hostName']];
|
||||||
while (in_array($userName, $existingUsers)) {
|
while (in_array($userName, $existingUsers)) {
|
||||||
$userName = $this->getNextUserName($userName);
|
$userName = $this->getNextUserName($userName);
|
||||||
}
|
}
|
||||||
$errMsg = $this->messages['uid'][10];
|
$errMsg = $this->messages['uid'][10];
|
||||||
array_push($errMsg, array($i, $userName, $rawAccounts[$i][$ids['posixAccount_hostName']]));
|
array_push($errMsg, array($i, $userName, $rawAccount[$ids['posixAccount_hostName']]));
|
||||||
$errors[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
elseif (get_preg($rawAccounts[$i][$ids['posixAccount_hostName']], 'hostname')) {
|
elseif (get_preg($rawAccount[$ids['posixAccount_hostName']], 'hostname')) {
|
||||||
$partialAccounts[$i]['uid'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
|
$partialAccounts[$i]['uid'] = $rawAccount[$ids['posixAccount_hostName']];
|
||||||
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
|
$partialAccounts[$i]['cn'] = $rawAccount[$ids['posixAccount_hostName']];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$errMsg = $this->messages['uid'][8];
|
$errMsg = $this->messages['uid'][8];
|
||||||
|
@ -2202,11 +2202,11 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$errors[] = $errMsg;
|
$errors[] = $errMsg;
|
||||||
}
|
}
|
||||||
// description
|
// description
|
||||||
if (isset($ids['posixAccount_description']) && isset($rawAccounts[$i][$ids['posixAccount_description']]) && ($rawAccounts[$i][$ids['posixAccount_description']] != '')) {
|
if (isset($ids['posixAccount_description']) && isset($rawAccount[$ids['posixAccount_description']]) && ($rawAccount[$ids['posixAccount_description']] != '')) {
|
||||||
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixAccount_description']];
|
$partialAccounts[$i]['description'] = $rawAccount[$ids['posixAccount_description']];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixAccount_hostName']];
|
$partialAccounts[$i]['description'] = $rawAccount[$ids['posixAccount_hostName']];
|
||||||
}
|
}
|
||||||
$partialAccounts[$i][$homedirAttrName] = '/dev/null';
|
$partialAccounts[$i][$homedirAttrName] = '/dev/null';
|
||||||
$partialAccounts[$i]['loginShell'] = '/bin/false';
|
$partialAccounts[$i]['loginShell'] = '/bin/false';
|
||||||
|
@ -2217,8 +2217,8 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$errorsTemp = array();
|
$errorsTemp = array();
|
||||||
$uids = $this->getNextUIDs(sizeof($needAutoUID), $errorsTemp);
|
$uids = $this->getNextUIDs(sizeof($needAutoUID), $errorsTemp);
|
||||||
if (is_array($uids)) {
|
if (is_array($uids)) {
|
||||||
for ($i = 0; $i < sizeof($needAutoUID); $i++) {
|
foreach ($needAutoUID as $i => $index) {
|
||||||
$partialAccounts[$i]['uidNumber'] = $uids[$i];
|
$partialAccounts[$index]['uidNumber'] = $uids[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2443,8 +2443,8 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
$uidList = $this->getUIDs();
|
$uidList = $this->getUIDs();
|
||||||
$uids = array();
|
$uids = array();
|
||||||
for ($i = 0; $i < sizeof($uidList); $i++) {
|
foreach ($uidList as $uid) {
|
||||||
if (($uidList[$i] <= $maxID) && ($uidList[$i] >= $minID)) $uids[] = $uidList[$i]; // ignore UIDs > maxID and UIDs < minID
|
if (($uid <= $maxID) && ($uid >= $minID)) $uids[] = $uid; // ignore UIDs > maxID and UIDs < minID
|
||||||
}
|
}
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
if (count($uids) != 0) {
|
if (count($uids) != 0) {
|
||||||
|
|
|
@ -139,16 +139,16 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
||||||
// check if all required attributes are given
|
// check if all required attributes are given
|
||||||
$invalidColumns = array();
|
$invalidColumns = array();
|
||||||
$id_names = array_keys($ids);
|
$id_names = array_keys($ids);
|
||||||
for ($i = 0; $i < sizeof($checkcolumns); $i++) {
|
foreach ($checkcolumns as $checkcolumn) {
|
||||||
for ($r = 0; $r < sizeof($data); $r++) {
|
foreach ($data as $dataRow) {
|
||||||
if ($data[$r][$checkcolumns[$i]] == "") {
|
if (empty($dataRow[$checkcolumn])) {
|
||||||
$invalidColumns[] = $id_names[$checkcolumns[$i]];
|
$invalidColumns[] = $id_names[$checkcolumn];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ($i = 0; $i < sizeof($data); $i++) {
|
foreach ($data as $dataRow) {
|
||||||
if ($data[$i][$ids['dn_rdn']] == "") {
|
if (empty($dataRow[$ids['dn_rdn']])) {
|
||||||
$invalidColumns[] = 'dn_rdn';
|
$invalidColumns[] = 'dn_rdn';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -162,8 +162,8 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
||||||
if (isset($columns[$i]['unique']) && ($columns[$i]['unique'] == true) && isset($ids[$columns[$i]['name']])) {
|
if (isset($columns[$i]['unique']) && ($columns[$i]['unique'] == true) && isset($ids[$columns[$i]['name']])) {
|
||||||
$colNumber = $ids[$columns[$i]['name']];
|
$colNumber = $ids[$columns[$i]['name']];
|
||||||
$values_given = array();
|
$values_given = array();
|
||||||
for ($r = 0; $r < sizeof($data); $r++) {
|
foreach ($data as $dataRow) {
|
||||||
$values_given[] = $data[$r][$colNumber];
|
$values_given[] = $dataRow[$colNumber];
|
||||||
}
|
}
|
||||||
$values_unique = array_unique($values_given);
|
$values_unique = array_unique($values_given);
|
||||||
if (sizeof($values_given) != sizeof($values_unique)) {
|
if (sizeof($values_given) != sizeof($values_unique)) {
|
||||||
|
@ -195,16 +195,16 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
||||||
$rdnList = getRDNAttributes($scope, $selectedModules);
|
$rdnList = getRDNAttributes($scope, $selectedModules);
|
||||||
$suffix = $_SESSION['config']->get_Suffix($scope);
|
$suffix = $_SESSION['config']->get_Suffix($scope);
|
||||||
// set DN
|
// set DN
|
||||||
for ($i = 0; $i < sizeof($accounts); $i++) {
|
foreach ($accounts as $i => $account) {
|
||||||
// check against list of possible RDN attributes
|
// check against list of possible RDN attributes
|
||||||
if (!in_array($data[$i][$ids['dn_rdn']], $rdnList)) {
|
if (!in_array($data[$i][$ids['dn_rdn']], $rdnList)) {
|
||||||
$errors[] = array(_('Account %s:') . ' dn_rdn ' . $accounts[$i][$data[$i][$ids['dn_rdn']]], _("Invalid RDN attribute!"), array($i));
|
$errors[] = array(_('Account %s:') . ' dn_rdn ' . $account[$data[$i][$ids['dn_rdn']]], _("Invalid RDN attribute!"), array($i));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$account_dn = $data[$i][$ids['dn_rdn']] . "=" . $accounts[$i][$data[$i][$ids['dn_rdn']]] . ",";
|
$account_dn = $data[$i][$ids['dn_rdn']] . "=" . $account[$data[$i][$ids['dn_rdn']]] . ",";
|
||||||
if ($data[$i][$ids['dn_suffix']] == "") $account_dn = $account_dn . $suffix;
|
if ($data[$i][$ids['dn_suffix']] == "") $account_dn = $account_dn . $suffix;
|
||||||
else $account_dn = $account_dn . $data[$i][$ids['dn_suffix']];
|
else $account_dn = $account_dn . $data[$i][$ids['dn_suffix']];
|
||||||
$accounts[$i]['dn'] = $account_dn;
|
$account['dn'] = $account_dn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// print errors if DN could not be built
|
// print errors if DN could not be built
|
||||||
|
|
Loading…
Reference in New Issue