1
|
|
|
<?php |
2
|
|
|
class LDAPFakeGateway extends LDAPGateway implements TestOnly |
|
|
|
|
3
|
|
|
{ |
4
|
|
|
public function __construct() |
5
|
|
|
{ |
6
|
|
|
// do nothing |
7
|
|
|
} |
8
|
|
|
|
9
|
|
|
private static $data = [ |
10
|
|
|
'groups' => [ |
11
|
|
|
'CN=Users,DC=playpen,DC=local' => [ |
12
|
|
|
['dn' => 'CN=Group1,CN=Users,DC=playpen,DC=local'], |
13
|
|
|
['dn' => 'CN=Group2,CN=Users,DC=playpen,DC=local'], |
14
|
|
|
['dn' => 'CN=Group3,CN=Users,DC=playpen,DC=local'], |
15
|
|
|
['dn' => 'CN=Group4,CN=Users,DC=playpen,DC=local'], |
16
|
|
|
['dn' => 'CN=Group5,CN=Users,DC=playpen,DC=local'] |
17
|
|
|
], |
18
|
|
|
'CN=Others,DC=playpen,DC=local' => [ |
19
|
|
|
['dn' => 'CN=Group6,CN=Others,DC=playpen,DC=local'], |
20
|
|
|
['dn' => 'CN=Group7,CN=Others,DC=playpen,DC=local'], |
21
|
|
|
['dn' => 'CN=Group8,CN=Others,DC=playpen,DC=local'] |
22
|
|
|
] |
23
|
|
|
], |
24
|
|
|
'users' => [ |
25
|
|
|
'123' => [ |
26
|
|
|
'distinguishedname' => 'CN=Joe,DC=playpen,DC=local', |
27
|
|
|
'objectguid' => '123', |
28
|
|
|
'cn' => 'jbloggs', |
29
|
|
|
'useraccountcontrol' => '1', |
30
|
|
|
'givenname' => 'Joe', |
31
|
|
|
'sn' => 'Bloggs', |
32
|
|
|
'mail' => '[email protected]' |
33
|
|
|
] |
34
|
|
|
] |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
public function authenticate($username, $password) |
38
|
|
|
{ |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getNodes($baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '') |
42
|
|
|
{ |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getGroups($baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '') |
46
|
|
|
{ |
47
|
|
|
if (isset($baseDn)) { |
48
|
|
|
return !empty(self::$data['groups'][$baseDn]) ? self::$data['groups'][$baseDn] : null; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getNestedGroups($dn, $baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = []) |
53
|
|
|
{ |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getGroupByGUID($guid, $baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = []) |
57
|
|
|
{ |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getUsers($baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '') |
61
|
|
|
{ |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getUserByGUID($guid, $baseDn = null, $scope = Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes = []) |
65
|
|
|
{ |
66
|
|
|
return [self::$data['users'][$guid]]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function update($dn, array $attributes) { |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function delete($dn, $recursively = false) { |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function move($fromDn, $toDn, $recursively = false) { |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function add($dn, array $attributes) { |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.