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');
|
||||
|
||||
$serverFactory = new ServerFactory();
|
||||
$auth = new BasicAuth('workgroup\test', 'test');
|
||||
$auth = new BasicAuth('test', 'workgroup', 'test');
|
||||
$server = $serverFactory->createServer('localhost', $auth);
|
||||
|
||||
$share = $server->getShare('test');
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ use Icewind\SMB\Server;
|
|||
require('vendor/autoload.php');
|
||||
|
||||
$host = 'localhost';
|
||||
$user = 'test\test';
|
||||
$user = 'test';
|
||||
$workgroup = 'test';
|
||||
$password = 'test';
|
||||
$share = 'test';
|
||||
|
||||
$auth = new \Icewind\SMB\BasicAuth($user, $password);
|
||||
$auth = new \Icewind\SMB\BasicAuth($user, $workgroup, $password);
|
||||
$serverFactory = new \Icewind\SMB\ServerFactory();
|
||||
|
||||
$server = $serverFactory->createServer($host, $auth);
|
||||
|
|
|
|||
|
|
@ -34,31 +34,15 @@ class BasicAuth implements IAuth {
|
|||
* BasicAuth constructor.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $workgroup
|
||||
* @param string $password
|
||||
*/
|
||||
public function __construct($username, $password) {
|
||||
list($workgroup, $username) = $this->splitUser($username);
|
||||
public function __construct($username, $workgroup, $password) {
|
||||
$this->username = $username;
|
||||
$this->workgroup = $workgroup;
|
||||
$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() {
|
||||
return $this->username;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class NativeShareTest extends AbstractShareTest {
|
|||
$this->config->host,
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class NativeStreamTest extends TestCase {
|
|||
$this->config->host,
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class NotifyHandlerTest extends TestCase {
|
|||
$this->config->host,
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class ServerTest extends TestCase {
|
|||
$this->config->host,
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
@ -53,6 +54,7 @@ class ServerTest extends TestCase {
|
|||
$this->config->host,
|
||||
new BasicAuth(
|
||||
uniqid(),
|
||||
'test',
|
||||
uniqid()
|
||||
),
|
||||
new System(),
|
||||
|
|
@ -69,6 +71,7 @@ class ServerTest extends TestCase {
|
|||
$this->config->host,
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
uniqid()
|
||||
),
|
||||
new System(),
|
||||
|
|
@ -85,6 +88,7 @@ class ServerTest extends TestCase {
|
|||
uniqid(),
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
@ -102,6 +106,7 @@ class ServerTest extends TestCase {
|
|||
$this->config->host . ';asd',
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class ShareTest extends AbstractShareTest {
|
|||
$this->config->host,
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
@ -44,6 +45,7 @@ class ShareTest extends AbstractShareTest {
|
|||
$this->config->host . ';asd',
|
||||
new BasicAuth(
|
||||
$this->config->user,
|
||||
'test',
|
||||
$this->config->password
|
||||
),
|
||||
new System(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue