From 624c94bff0efc52ddf11f9c9208f59c733e6ff19 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 23 Oct 2019 21:25:33 +0200 Subject: [PATCH] updated connect() method --- lam/lib/modules/quota.inc | 25 ++++++++++++++++--------- lam/lib/modules/sambaSamAccount.inc | 8 +++----- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index 4c9f8b2f..7ce81b8b 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -174,11 +174,15 @@ class quota extends baseModule { $userName = '+'; if (($this->getAccountContainer() != null) && !$this->getAccountContainer()->isNewAccount) { if ($this->get_scope() == 'user') { - if (!isset($this->attributes['uid'][0])) return; + if (!isset($this->attributes['uid'][0])) { + return; + } $userName = $this->attributes['uid'][0]; } else if ($this->get_scope() == 'group') { - if (!isset($this->attributes['cn'][0])) return; + if (!isset($this->attributes['cn'][0])) { + return; + } $userName = $this->attributes['cn'][0]; } } @@ -188,7 +192,7 @@ class quota extends baseModule { $server = $lamdaemonServer->getServer(); // get quotas $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remote->connect($lamdaemonServer); $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope()))); $remote->disconnect(); if (empty($quotas)) { @@ -289,7 +293,8 @@ class quota extends baseModule { $quotastring .= ',' . $this->getQuotaNumber($this->quota[$server][$i][7]) . ':'; } $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remoteServer = $_SESSION['config']->getScriptServerByName($server); + $remote->connect($remoteServer); $remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n"))); $remote->disconnect(); } @@ -367,7 +372,8 @@ class quota extends baseModule { $i++; } $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remoteServer = $_SESSION['config']->getScriptServerByName($server); + $remote->connect($remoteServer); $remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n"))); $remote->disconnect(); } @@ -528,7 +534,7 @@ class quota extends baseModule { } // Get quotas $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remote->connect($lamdaemonServer); $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))); $remote->disconnect(); if (empty($quotas)) { @@ -592,7 +598,7 @@ class quota extends baseModule { $id = $this->replaceSpecialChars($server); // Get quotas $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remote->connect($lamdaemonServer); $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))); $remote->disconnect(); $dirs = explode(":", $quotas); @@ -753,7 +759,7 @@ class quota extends baseModule { $server = $lamdaemonServer->getServer(); // Get quotas $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remote->connect($lamdaemonServer); $quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope()))); $remote->disconnect(); $dirs = explode(":", $quotas); @@ -883,7 +889,8 @@ class quota extends baseModule { $quotaString = implode(quota::$SPLIT_DELIMITER, array($name, "quota", "set", $this->get_scope(), $dir . ',' . implode(',', $temp['accounts'][$name][$mountPoints[$m]]) . "\n")); $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remoteServer = $_SESSION['config']->getScriptServerByName($server); + $remote->connect($remoteServer); $result = $remote->execute($quotaString); $remote->disconnect(); if (!empty($result)) { diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index e0753c91..f98f9d75 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -1545,10 +1545,9 @@ class sambaSamAccount extends baseModule implements passwordService { $remoteServers = $_SESSION['config']->getConfiguredScriptServers(); for ($i = 0; $i < sizeof($remoteServers); $i++) { $remoteServer = $remoteServers[$i]; - $server = $remoteServer->getServer(); $label = $remoteServer->getLabel(); $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remote->connect($remoteServer); $result = $remote->execute( implode( self::$SPLIT_DELIMITER, @@ -1617,10 +1616,9 @@ class sambaSamAccount extends baseModule implements passwordService { $remoteServers = $_SESSION['config']->getConfiguredScriptServers(); for ($i = 0; $i < sizeof($remoteServers); $i++) { $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); + $remote->connect($remoteServer); $result = $remote->execute( implode( self::$SPLIT_DELIMITER, @@ -1645,7 +1643,7 @@ class sambaSamAccount extends baseModule implements passwordService { } elseif (isset($_POST['form_subpage_' . get_class($this) . '_homedir_delete_' . $i])) { $remote = new \LAM\REMOTE\Remote(); - $remote->connect($server); + $remote->connect($remoteServer); $result = $remote->execute( implode( self::$SPLIT_DELIMITER,