diff --git a/lam/docs/manual-sources/chapter-installation.xml b/lam/docs/manual-sources/chapter-installation.xml
index 45961773..f133529b 100644
--- a/lam/docs/manual-sources/chapter-installation.xml
+++ b/lam/docs/manual-sources/chapter-installation.xml
@@ -332,6 +332,20 @@
https://hub.docker.com/r/ldapaccountmanager/lampro
+
+ Configuration files
+
+ All configuration files are stored in:
+
+
+
+ /etc/ldap-account-manager
+
+
+
+ /var/lib/ldap-account-manager
+
+
diff --git a/lam/lib/config.inc b/lam/lib/config.inc
index c6e999aa..8c3896c5 100644
--- a/lam/lib/config.inc
+++ b/lam/lib/config.inc
@@ -1,5 +1,6 @@
scriptServer;
}
+ /**
+ * Returns the list of configureed servers.
+ *
+ * @return RemoteServerConfiguration[] servers
+ */
+ public function getConfiguredScriptServers() {
+ $servers = array();
+ if (empty($this->scriptServer)) {
+ return $servers;
+ }
+ $serverChunks = explode(';', $this->scriptServer);
+ foreach ($serverChunks as $serverChunk) {
+ if (empty($serverChunk)) {
+ continue;
+ }
+ $serverSettings = explode(':', $serverChunk);
+ $serverName = $serverSettings[0];
+ $serverLabel = isset($serverSettings[1]) ? $serverSettings[1] : null;
+ $serverHomedirPrefix = isset($serverSettings[2]) ? $serverSettings[2] : null;
+ $servers[] = new RemoteServerConfiguration($serverName, $serverLabel, $serverHomedirPrefix);
+ }
+ return $servers;
+ }
+
/**
* Sets the servers of the external script
*
@@ -1470,21 +1495,25 @@ class LAMConfig {
// Explode name and IP, if a name exists
if (preg_match("/:/", $arr_value)) {
$arr_value_explode = explode(":", $arr_value);
- $ip = $arr_value_explode[1];
$servername = $arr_value_explode[0];
+ $label = $arr_value_explode[1];
+ $homedirPrefix = isset($arr_value_explode[2]) ? $arr_value_explode[2] : '';
}
else {
- $ip = $arr_value;
- $servername = "";
+ $servername = $arr_value;
+ $label = '';
+ $homedirPrefix = '';
}
- if (isset($ip) && is_string($ip) && preg_match("/^[a-z0-9-]+(\\.[a-z0-9-]+)*(,[0-9]+)?$/i", $ip)) {
- // Check if the IP has a server name
- if (!empty($servername)) {
- $valid_ips[] = $servername.":".$ip;
+ if (isset($servername) && is_string($servername) && preg_match("/^[a-z0-9-]+(\\.[a-z0-9-]+)*(,[0-9]+)?$/i", $servername)) {
+ $serverData = array($servername);
+ if (!empty($label)) {
+ $serverData[] = $label;
}
- else {
- $valid_ips[] = $ip;
+ if (!empty($homedirPrefix)) {
+ $serverData[] = $homedirPrefix;
}
+ $serverChunk = implode(':', $serverData);
+ $valid_ips[] = $serverChunk;
}
else {
// wrong format
@@ -1492,7 +1521,7 @@ class LAMConfig {
}
}
// Check that the array is not empty
- if ($array_string > 0) {
+ if (!empty($array_string)) {
$this->scriptServer = implode(";", $valid_ips);
return true;
}
diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc
index 692a9c72..40532731 100644
--- a/lam/lib/modules/posixAccount.inc
+++ b/lam/lib/modules/posixAccount.inc
@@ -199,6 +199,11 @@ class posixAccount extends baseModule implements passwordService {
$return['upload_preDepends'] = array('inetOrgPerson');
// user specific upload options
if (($this->get_scope() == 'user') && isLoggedIn()) {
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
+ $lamdaemonOptions = array();
+ foreach ($lamdaemonServers as $lamdaemonServer) {
+ $lamdaemonOptions[] = $lamdaemonServer->getServer();
+ }
$return['upload_columns'] = array(
array(
'name' => 'posixAccount_userName',
@@ -239,7 +244,7 @@ class posixAccount extends baseModule implements passwordService {
'description' => _('Create home directory'),
'help' => 'createhomedir',
'example' => 'localhost',
- 'values' => $_SESSION['config']->get_scriptServers()
+ 'values' => implode(', ', $lamdaemonOptions)
),
array(
'name' => 'posixAccount_shell',
@@ -702,18 +707,14 @@ class posixAccount extends baseModule implements passwordService {
$messages = array_merge($messages, $this->setExopPassword($this->moduleSettings));
// create home directories if needed
$homeDirAttr = $this->getHomedirAttrName($modules);
+ $lamdaemonServerList = $_SESSION['config']->getConfiguredScriptServers();
+ $lamdaemonServerNames = array();
+ foreach ($lamdaemonServerList as $lamdaemonServer) {
+ $lamdaemonServerNames[] = $lamdaemonServer->getServer();
+ }
if (sizeof($this->lamdaemonServers) > 0) {
- $server = null;
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- $server = $temp[0];
- if (isset($temp[1])) {
- if (!in_array($temp[1], $this->lamdaemonServers)) {
- continue;
- }
- }
- elseif (!in_array($temp[0], $this->lamdaemonServers)) {
+ foreach ($lamdaemonServerNames as $server) {
+ if (!in_array($server, $this->lamdaemonServers)) {
continue;
}
$remote = new \LAM\REMOTE\Remote();
@@ -746,13 +747,7 @@ class posixAccount extends baseModule implements passwordService {
// move home directory if needed
if (!empty($this->orig[$homeDirAttr][0]) && !empty($this->attributes[$homeDirAttr][0])
&& ($this->orig[$homeDirAttr][0] != $this->attributes[$homeDirAttr][0])) {
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- if (empty($lamdaemonServers[$i])) {
- continue;
- }
- $temp = explode(":", $lamdaemonServers[$i]);
- $server = $temp[0];
+ foreach ($lamdaemonServerNames as $server) {
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
$result = $remote->execute(
@@ -779,13 +774,7 @@ class posixAccount extends baseModule implements passwordService {
// set new group on homedirectory
if (!empty($this->orig[$homeDirAttr][0]) && !empty($this->attributes[$homeDirAttr][0])
&& ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0])) {
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- if (empty($lamdaemonServers[$i])) {
- continue;
- }
- $temp = explode(":", $lamdaemonServers[$i]);
- $server = $temp[0];
+ foreach ($lamdaemonServerNames as $server) {
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
$result = $remote->execute(
@@ -941,16 +930,12 @@ class posixAccount extends baseModule implements passwordService {
$modules = $this->getAccountContainer()->get_type()->getModules();
$homeDirAttr = $this->getHomedirAttrName($modules);
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- $lamdaemonServers[$i] = $temp[0];
- }
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
// try to delete directory on all servers
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
+ foreach ($lamdaemonServers as $lamdaemonServer) {
$remote = new \LAM\REMOTE\Remote();
try {
- $remote->connect($lamdaemonServers[$i]);
+ $remote->connect($lamdaemonServer->getServer());
$result = $remote->execute(
implode(
self::$SPLIT_DELIMITER,
@@ -1036,7 +1021,9 @@ class posixAccount extends baseModule implements passwordService {
$this->attributes['loginShell'][0] = $_POST['loginShell'];
}
if (!$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) {
- if (isset($_POST['gecos'])) $this->attributes['gecos'][0] = $_POST['gecos'];
+ if (isset($_POST['gecos'])) {
+ $this->attributes['gecos'][0] = $_POST['gecos'];
+ }
}
if (isset($this->orig['uid'][0]) && ($this->orig['uid'][0] != '') && (trim($_POST['uid']) != $this->attributes['uid'][0])) {
$errors[] = $this->messages['uid'][0];
@@ -1067,16 +1054,11 @@ class posixAccount extends baseModule implements passwordService {
$errors[] = $errorMessage;
}
// get list of DNS names or IPs
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- if (isset($temp[1])) $lamdaemonServers[$i] = $temp[1];
- else $lamdaemonServers[$i] = $temp[0];
- }
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
$this->lamdaemonServers = array();
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
if (isset($_POST['createhomedir_' . $h]) && ($_POST['createhomedir_' . $h] = 'on')) {
- $this->lamdaemonServers[] = $lamdaemonServers[$h];
+ $this->lamdaemonServers[] = $lamdaemonServers[$h]->getServer();
}
}
if (isset($_POST['homeDirectory'])) {
@@ -1483,12 +1465,11 @@ class posixAccount extends baseModule implements passwordService {
function process_homedir() {
$return = array();
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
$modules = $this->getAccountContainer()->get_type()->getModules();
$homeDirAttr = $this->getHomedirAttrName($modules);
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- $server = $temp[0];
+ $server = $lamdaemonServers[$i]->getServer();
if (isset($_POST['form_subpage_' . get_class($this) . '_homedir_create_' . $i])) {
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
@@ -1676,21 +1657,12 @@ class posixAccount extends baseModule implements passwordService {
if (($_SESSION['config']->get_scriptPath() != null) && ($_SESSION['config']->get_scriptPath() != '')) {
if ($this->getAccountContainer()->isNewAccount) {
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- if (isset($temp[1])) {
- $lamdaemonServers[$i] = $temp[1];
- }
- else {
- $lamdaemonServers[$i] = $temp[0];
- }
- }
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
$homeDirLabel = new htmlOutputText(_('Create home directory'));
$return->addLabel($homeDirLabel);
$homeServerContainer = new htmlTable();
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
- $homeServerContainer->addElement(new htmlTableExtendedInputCheckbox('createhomedir_' . $h, in_array($lamdaemonServers[$h], $this->lamdaemonServers), $lamdaemonServers[$h], null, false));
+ $homeServerContainer->addElement(new htmlTableExtendedInputCheckbox('createhomedir_' . $h, in_array($lamdaemonServers[$h], $this->lamdaemonServers), $lamdaemonServers[$h]->getLabel(), null, false));
if ($h === 0) {
$homeDirHelp = new htmlHelpLink('createhomedir');
$homeServerContainer->addElement($homeDirHelp);
@@ -1936,14 +1908,10 @@ class posixAccount extends baseModule implements passwordService {
$return->addField(new htmlOutputText($this->attributes[$homeDirAttr][0]));
$return->addVerticalSpacer('2rem');
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- $server = $temp[0];
- $label = $temp[0];
- if (isset($temp[1])) {
- $label = $temp[1];
- }
+ $server = $lamdaemonServers[$i]->getServer();
+ $label = $lamdaemonServers[$i]->getLabel();
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
$result = $remote->execute(
@@ -2036,14 +2004,11 @@ class posixAccount extends baseModule implements passwordService {
// lamdaemon settings
if ($_SESSION['config']->get_scriptPath() != null) {
$return->add(new htmlSubTitle(_('Create home directory')), 12);
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- if (isset($temp[1])) $lamdaemonServers[$i] = $temp[1];
- else $lamdaemonServers[$i] = $temp[0];
- }
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
- $return->add(new htmlResponsiveInputCheckbox('posixAccount_createHomedir_' . $h, in_array($lamdaemonServers[$h], $this->lamdaemonServers), $lamdaemonServers[$h], 'createhomedir', false), 12);
+ $server = $lamdaemonServers[$h]->getServer();
+ $label = $lamdaemonServers[$h]->getLabel();
+ $return->add(new htmlResponsiveInputCheckbox('posixAccount_createHomedir_' . $h, in_array($server, $this->lamdaemonServers), $label, 'createhomedir', false), 12);
}
}
}
@@ -2090,16 +2055,11 @@ class posixAccount extends baseModule implements passwordService {
}
// lamdaemon
if (($this->get_scope() == 'user') && $this->getAccountContainer()->isNewAccount) {
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($i = 0; $i < sizeof($lamdaemonServers); $i++) {
- $temp = explode(":", $lamdaemonServers[$i]);
- if (isset($temp[1])) $lamdaemonServers[$i] = $temp[1];
- else $lamdaemonServers[$i] = $temp[0];
- }
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
$this->lamdaemonServers = array();
for ($h = 0; $h < sizeof($lamdaemonServers); $h++) {
if (isset($profile['posixAccount_createHomedir_' . $h][0]) && ($profile['posixAccount_createHomedir_' . $h][0] == 'true')) {
- $this->lamdaemonServers[] = $lamdaemonServers[$h];
+ $this->lamdaemonServers[] = $lamdaemonServers[$h]->getServer();
}
}
}
diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc
index 6b8aa72a..4c9f8b2f 100644
--- a/lam/lib/modules/quota.inc
+++ b/lam/lib/modules/quota.inc
@@ -183,10 +183,9 @@ class quota extends baseModule {
}
}
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- $server = $temp[0];
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
+ foreach ($lamdaemonServers as $lamdaemonServer) {
+ $server = $lamdaemonServer->getServer();
// get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
@@ -277,14 +276,6 @@ class quota extends baseModule {
$id = $this->getCn();
}
// get list of lamdaemon servers
- $serverDescriptions = array();
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- if (isset($temp[1])) {
- $serverDescriptions[$temp[0]] = $temp[1];
- }
- }
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
@@ -366,14 +357,6 @@ class quota extends baseModule {
$id = $this->getCn();
}
// get list of lamdaemon servers
- $serverDescriptions = array();
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- if (isset($temp[1])) {
- $serverDescriptions[$temp[0]] = $temp[1];
- }
- }
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
@@ -403,14 +386,6 @@ class quota extends baseModule {
}
$errors = array();
// get list of lamdaemon servers
- $serverDescriptions = array();
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- if (isset($temp[1])) {
- $serverDescriptions[$temp[0]] = $temp[1];
- }
- }
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
@@ -467,19 +442,17 @@ class quota extends baseModule {
}
// get list of lamdaemon servers
$serverDescriptions = array();
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- if (isset($temp[1])) {
- $serverDescriptions[$temp[0]] = $temp[1];
- }
+ $lamdaemonServer = $lamdaemonServers[$s];
+ $serverDescriptions[$lamdaemonServer->getServer()] = $lamdaemonServer->getLabel();
}
$servers = array_keys($this->quota);
for ($q = 0; $q < sizeof($servers); $q++) {
$server = $servers[$q];
$id = $this->replaceSpecialChars($server);
$title = $server;
- if (isset($serverDescriptions[$server])) {
+ if ($serverDescriptions[$server] != $server) {
$title = $serverDescriptions[$server] . " (" . $server . ")";
}
$return->add(new htmlSubTitle($title), 12);
@@ -544,15 +517,14 @@ class quota extends baseModule {
$return = new htmlResponsiveRow();
$optionsAvailable = false;
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
try {
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- $server = $temp[0];
+ foreach ($lamdaemonServers as $lamdaemonServer) {
+ $server = $lamdaemonServer->getServer();
$id = $this->replaceSpecialChars($server);
- $description = $temp[0];
- if (isset($temp[1])) {
- $description = $temp[1] . ' (' . $temp[0] . ')';
+ $description = $lamdaemonServer->getLabel();
+ if ($description != $server) {
+ $description = $description . ' (' . $server . ')';
}
// Get quotas
$remote = new \LAM\REMOTE\Remote();
@@ -614,10 +586,9 @@ class quota extends baseModule {
function check_profileOptions($options, $typeId) {
$return = array();
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- $server = $temp[0];
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
+ foreach ($lamdaemonServers as $lamdaemonServer) {
+ $server = $lamdaemonServer->getServer();
$id = $this->replaceSpecialChars($server);
// Get quotas
$remote = new \LAM\REMOTE\Remote();
@@ -717,13 +688,12 @@ class quota extends baseModule {
if (sizeof($this->quota) > 0) {
$pdfTable = new PDFTable();
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- $server = $temp[0];
- $description = $server;
- if (isset($temp[1])) {
- $description = $temp[1] . " (" . $server . ")";
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
+ foreach ($lamdaemonServers as $lamdaemonServer) {
+ $server = $lamdaemonServer->getServer();
+ $description = $lamdaemonServer->getLabel();
+ if ($description != $server) {
+ $description = $description . " (" . $server . ")";
}
if (!isset($this->quota[$server]) || (sizeof($this->quota[$server]) < 1)) {
continue;
@@ -778,10 +748,9 @@ class quota extends baseModule {
$return = array();
if (sizeof($this->quota) > 0) {
// get list of lamdaemon servers
- $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers());
- for ($s = 0; $s < sizeof($lamdaemonServers); $s++) {
- $temp = explode(":", $lamdaemonServers[$s]);
- $server = $temp[0];
+ $lamdaemonServers = $_SESSION['config']->getConfiguredScriptServers();
+ foreach ($lamdaemonServers as $lamdaemonServer) {
+ $server = $lamdaemonServer->getServer();
// Get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc
index 49b25d3b..603f6d6b 100644
--- a/lam/lib/modules/sambaSamAccount.inc
+++ b/lam/lib/modules/sambaSamAccount.inc
@@ -1542,14 +1542,11 @@ class sambaSamAccount extends baseModule implements passwordService {
$homeServerContainer = new htmlTable();
$homeServerContainer->colspan = 5;
// get list of remote servers
- $remoteServers = explode(";", $_SESSION['config']->get_scriptServers());
+ $remoteServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($remoteServers); $i++) {
- $temp = explode(":", $remoteServers[$i]);
- $server = $temp[0];
- $label = $temp[0];
- if (isset($temp[1])) {
- $label = $temp[1];
- }
+ $remoteServer = $remoteServers[$i];
+ $server = $remoteServer->getServer();
+ $label = $remoteServer->getLabel();
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
$result = $remote->execute(
@@ -1617,10 +1614,10 @@ class sambaSamAccount extends baseModule implements passwordService {
return;
}
// get list of remote servers
- $remoteServers = explode(";", $_SESSION['config']->get_scriptServers());
+ $remoteServers = $_SESSION['config']->getConfiguredScriptServers();
for ($i = 0; $i < sizeof($remoteServers); $i++) {
- $temp = explode(":", $remoteServers[$i]);
- $server = $temp[0];
+ $remoteServer = $remoteServers[$i];
+ $server = $remoteServer->getServer();
if (isset($_POST['form_subpage_' . get_class($this) . '_homedir_create_' . $i])) {
$remote = new \LAM\REMOTE\Remote();
$remote->connect($server);
@@ -1640,10 +1637,9 @@ class sambaSamAccount extends baseModule implements passwordService {
// remote command results
if (!empty($result)) {
$singleresult = explode(",", $result);
- if (is_array($singleresult)) {
- if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) {
- $return[] = $singleresult;
- }
+ if (is_array($singleresult)
+ && (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO'))) {
+ $return[] = $singleresult;
}
}
}
@@ -1665,10 +1661,9 @@ class sambaSamAccount extends baseModule implements passwordService {
// remote command results
if (!empty($result)) {
$singleresult = explode(",", $result);
- if (is_array($singleresult)) {
- if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) {
- $return[] = $singleresult;
- }
+ if (is_array($singleresult)
+ && (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO'))) {
+ $return[] = $singleresult;
}
}
}
diff --git a/lam/lib/remote.inc b/lam/lib/remote.inc
index 9190d7fd..eb71aa14 100644
--- a/lam/lib/remote.inc
+++ b/lam/lib/remote.inc
@@ -174,4 +174,63 @@ class Remote {
}
+/**
+ * Server configuration.
+ *
+ * @author Roland Gruber
+ */
+class RemoteServerConfiguration {
+
+ private $server;
+ private $label;
+ private $homeDirPrefix;
+
+ /**
+ * Constructor
+ *
+ * @param string $server server DNS name
+ * @param string $label label for GUI
+ * @param string $homeDirPrefix prefix for home directories
+ */
+ public function __construct($server, $label, $homeDirPrefix) {
+ $this->server = $server;
+ $this->label = $label;
+ if (empty($label)) {
+ $this->label = $server;
+ }
+ $this->homeDirPrefix = $homeDirPrefix;
+ if (empty($homeDirPrefix)) {
+ $this->homeDirPrefix = '';
+ }
+ }
+
+ /**
+ * Returns the server's DNS name.
+ *
+ * @return string server name
+ */
+ public function getServer() {
+ return $this->server;
+ }
+
+ /**
+ * Returns a descriptive label.
+ *
+ * @return string label
+ */
+ public function getLabel() {
+ return $this->label;
+ }
+
+ /**
+ * Returns the prefix for user home directories.
+ *
+ * @return string prefix for user home directories
+ */
+ public function getHomeDirPrefix() {
+ return $this->homeDirPrefix;
+ }
+
+}
+
?>
diff --git a/lam/templates/tests/lamdaemonTest.php b/lam/templates/tests/lamdaemonTest.php
index f69043af..85d0fc30 100644
--- a/lam/templates/tests/lamdaemonTest.php
+++ b/lam/templates/tests/lamdaemonTest.php
@@ -15,7 +15,7 @@ use \htmlResponsiveRow;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
- Copyright (C) 2006 - 2018 Roland Gruber
+ Copyright (C) 2006 - 2019 Roland Gruber
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
@@ -51,7 +51,9 @@ startSecureSession();
enforceUserIsLoggedIn();
// die if no write access
-if (!checkIfWriteAccessIsAllowed()) die();
+if (!checkIfWriteAccessIsAllowed()) {
+ die();
+}
checkIfToolIsActive('toolTests');
@@ -64,33 +66,31 @@ echo "