mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
make workgroup explicit
This commit is contained in:
parent
7797d463d7
commit
bdda31975d
8 changed files with 16 additions and 21 deletions
|
|
@ -26,7 +26,7 @@ use Icewind\SMB\BasicAuth;
|
||||||
require('vendor/autoload.php');
|
require('vendor/autoload.php');
|
||||||
|
|
||||||
$serverFactory = new ServerFactory();
|
$serverFactory = new ServerFactory();
|
||||||
$auth = new BasicAuth('workgroup\test', 'test');
|
$auth = new BasicAuth('test', 'workgroup', 'test');
|
||||||
$server = $serverFactory->createServer('localhost', $auth);
|
$server = $serverFactory->createServer('localhost', $auth);
|
||||||
|
|
||||||
$share = $server->getShare('test');
|
$share = $server->getShare('test');
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,12 @@ use Icewind\SMB\Server;
|
||||||
require('vendor/autoload.php');
|
require('vendor/autoload.php');
|
||||||
|
|
||||||
$host = 'localhost';
|
$host = 'localhost';
|
||||||
$user = 'test\test';
|
$user = 'test';
|
||||||
|
$workgroup = 'test';
|
||||||
$password = 'test';
|
$password = 'test';
|
||||||
$share = 'test';
|
$share = 'test';
|
||||||
|
|
||||||
$auth = new \Icewind\SMB\BasicAuth($user, $password);
|
$auth = new \Icewind\SMB\BasicAuth($user, $workgroup, $password);
|
||||||
$serverFactory = new \Icewind\SMB\ServerFactory();
|
$serverFactory = new \Icewind\SMB\ServerFactory();
|
||||||
|
|
||||||
$server = $serverFactory->createServer($host, $auth);
|
$server = $serverFactory->createServer($host, $auth);
|
||||||
|
|
|
||||||
|
|
@ -34,31 +34,15 @@ class BasicAuth implements IAuth {
|
||||||
* BasicAuth constructor.
|
* BasicAuth constructor.
|
||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
|
* @param string $workgroup
|
||||||
* @param string $password
|
* @param string $password
|
||||||
*/
|
*/
|
||||||
public function __construct($username, $password) {
|
public function __construct($username, $workgroup, $password) {
|
||||||
list($workgroup, $username) = $this->splitUser($username);
|
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
$this->workgroup = $workgroup;
|
$this->workgroup = $workgroup;
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Split workgroup from username
|
|
||||||
*
|
|
||||||
* @param $user
|
|
||||||
* @return string[] [$workgroup, $user]
|
|
||||||
*/
|
|
||||||
private function splitUser($user) {
|
|
||||||
if (strpos($user, '/')) {
|
|
||||||
return explode('/', $user, 2);
|
|
||||||
} elseif (strpos($user, '\\')) {
|
|
||||||
return explode('\\', $user);
|
|
||||||
} else {
|
|
||||||
return array(null, $user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUsername() {
|
public function getUsername() {
|
||||||
return $this->username;
|
return $this->username;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class NativeShareTest extends AbstractShareTest {
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ class NativeStreamTest extends TestCase {
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ class NotifyHandlerTest extends TestCase {
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class ServerTest extends TestCase {
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
@ -53,6 +54,7 @@ class ServerTest extends TestCase {
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
uniqid(),
|
uniqid(),
|
||||||
|
'test',
|
||||||
uniqid()
|
uniqid()
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
@ -69,6 +71,7 @@ class ServerTest extends TestCase {
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
uniqid()
|
uniqid()
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
@ -85,6 +88,7 @@ class ServerTest extends TestCase {
|
||||||
uniqid(),
|
uniqid(),
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
@ -102,6 +106,7 @@ class ServerTest extends TestCase {
|
||||||
$this->config->host . ';asd',
|
$this->config->host . ';asd',
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class ShareTest extends AbstractShareTest {
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
@ -44,6 +45,7 @@ class ShareTest extends AbstractShareTest {
|
||||||
$this->config->host . ';asd',
|
$this->config->host . ';asd',
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
$this->config->user,
|
$this->config->user,
|
||||||
|
'test',
|
||||||
$this->config->password
|
$this->config->password
|
||||||
),
|
),
|
||||||
new System(),
|
new System(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue