1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\ActiveDirectory\Tests\Model; |
4
|
|
|
|
5
|
|
|
use SilverStripe\ActiveDirectory\Model\LDAPGateway; |
6
|
|
|
use SilverStripe\Dev\TestOnly; |
7
|
|
|
use Zend\Ldap\Ldap; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @package activedirectory |
11
|
|
|
*/ |
12
|
|
|
class LDAPFakeGateway extends LDAPGateway implements TestOnly |
13
|
|
|
{ |
14
|
|
|
public function __construct() |
15
|
|
|
{ |
16
|
|
|
// do nothing |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
private static $data = [ |
20
|
|
|
'groups' => [ |
21
|
|
|
'CN=Users,DC=playpen,DC=local' => [ |
22
|
|
|
['dn' => 'CN=Group1,CN=Users,DC=playpen,DC=local'], |
23
|
|
|
['dn' => 'CN=Group2,CN=Users,DC=playpen,DC=local'], |
24
|
|
|
['dn' => 'CN=Group3,CN=Users,DC=playpen,DC=local'], |
25
|
|
|
['dn' => 'CN=Group4,CN=Users,DC=playpen,DC=local'], |
26
|
|
|
['dn' => 'CN=Group5,CN=Users,DC=playpen,DC=local'] |
27
|
|
|
], |
28
|
|
|
'CN=Others,DC=playpen,DC=local' => [ |
29
|
|
|
['dn' => 'CN=Group6,CN=Others,DC=playpen,DC=local'], |
30
|
|
|
['dn' => 'CN=Group7,CN=Others,DC=playpen,DC=local'], |
31
|
|
|
['dn' => 'CN=Group8,CN=Others,DC=playpen,DC=local'] |
32
|
|
|
] |
33
|
|
|
], |
34
|
|
|
'users' => [ |
35
|
|
|
'123' => [ |
36
|
|
|
'distinguishedname' => 'CN=Joe,DC=playpen,DC=local', |
37
|
|
|
'objectguid' => '123', |
38
|
|
|
'cn' => 'jbloggs', |
39
|
|
|
'useraccountcontrol' => '1', |
40
|
|
|
'givenname' => 'Joe', |
41
|
|
|
'sn' => 'Bloggs', |
42
|
|
|
'mail' => '[email protected]' |
43
|
|
|
] |
44
|
|
|
] |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
public function authenticate($username, $password) |
48
|
|
|
{ |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getNodes($baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '') |
52
|
|
|
{ |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getGroups($baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '') |
56
|
|
|
{ |
57
|
|
|
if (isset($baseDn)) { |
58
|
|
|
return !empty(self::$data['groups'][$baseDn]) ? self::$data['groups'][$baseDn] : null; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getNestedGroups($dn, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = []) |
63
|
|
|
{ |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getGroupByGUID($guid, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = []) |
67
|
|
|
{ |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getUsers($baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '') |
71
|
|
|
{ |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getUserByGUID($guid, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = []) |
75
|
|
|
{ |
76
|
|
|
return [self::$data['users'][$guid]]; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function update($dn, array $attributes) |
80
|
|
|
{ |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function delete($dn, $recursively = false) |
84
|
|
|
{ |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function move($fromDn, $toDn, $recursively = false) |
88
|
|
|
{ |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function add($dn, array $attributes) |
92
|
|
|
{ |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|