1 | <?php |
||
31 | class LdapUserProvider implements UserProviderInterface |
||
32 | { |
||
33 | /** |
||
34 | * @var LdapManager |
||
35 | */ |
||
36 | protected $ldap; |
||
37 | |||
38 | /** |
||
39 | * @var EventDispatcherInterface |
||
40 | */ |
||
41 | protected $dispatcher; |
||
42 | |||
43 | /** |
||
44 | * @var LdapRoleMapper |
||
45 | */ |
||
46 | protected $roleMapper; |
||
47 | |||
48 | /** |
||
49 | * @var array Default attributes selected for the Advanced User Interface. |
||
50 | */ |
||
51 | protected $defaultAttributes = [ |
||
52 | 'username', |
||
53 | 'guid', |
||
54 | 'accountExpirationDate', |
||
55 | 'enabled', |
||
56 | 'groups', |
||
57 | 'locked', |
||
58 | 'passwordMustChange', |
||
59 | ]; |
||
60 | |||
61 | /** |
||
62 | * @var array Any additional LDAP attributes to select. |
||
63 | */ |
||
64 | protected $additionalAttributes = []; |
||
65 | |||
66 | /** |
||
67 | * @var string |
||
68 | */ |
||
69 | protected $userClass = LdapUser::class; |
||
70 | |||
71 | /** |
||
72 | * @var string The object type to search LDAP for. |
||
73 | */ |
||
74 | protected $ldapObjectType = LdapObjectType::USER; |
||
75 | |||
76 | /** |
||
77 | * @var string The container/OU to search for the user under. |
||
78 | */ |
||
79 | protected $searchBase; |
||
80 | |||
81 | /** |
||
82 | * @var bool Whether or not user attributes should be re-queried on a refresh. |
||
83 | */ |
||
84 | protected $refreshAttributes = true; |
||
85 | |||
86 | /** |
||
87 | * @var bool Whether or not user roles should be re-queried on a refresh. |
||
88 | */ |
||
89 | protected $refreshRoles = true; |
||
90 | |||
91 | /** |
||
92 | * @param LdapManager $ldap |
||
93 | * @param EventDispatcherInterface $dispatcher |
||
94 | * @param LdapRoleMapper $roleMapper |
||
95 | */ |
||
96 | public function __construct(LdapManager $ldap, EventDispatcherInterface $dispatcher, LdapRoleMapper $roleMapper) |
||
102 | |||
103 | /** |
||
104 | * Set the user class to be instantiated and returned from the LDAP provider. |
||
105 | * |
||
106 | * @param string $class |
||
107 | */ |
||
108 | public function setUserClass($class) |
||
120 | |||
121 | /** |
||
122 | * Set any additional attributes to be selected for the LDAP user. |
||
123 | * |
||
124 | * @param array $attributes |
||
125 | */ |
||
126 | public function setAttributes(array $attributes) |
||
130 | |||
131 | /** |
||
132 | * Set the LDAP object type that will be searched for. |
||
133 | * |
||
134 | * @param string $type |
||
135 | */ |
||
136 | public function setLdapObjectType($type) |
||
140 | |||
141 | /** |
||
142 | * @param string $searchBase |
||
143 | */ |
||
144 | public function setSearchBase($searchBase) |
||
148 | |||
149 | /** |
||
150 | * @param bool $refreshRoles |
||
151 | */ |
||
152 | public function setRefreshRoles($refreshRoles) |
||
156 | |||
157 | /** |
||
158 | * @param bool $refreshAttributes |
||
159 | */ |
||
160 | public function setRefreshAttributes($refreshAttributes) |
||
164 | |||
165 | /** |
||
166 | * {@inheritdoc} |
||
167 | */ |
||
168 | public function loadUserByUsername($username) |
||
178 | |||
179 | /** |
||
180 | * {@inheritdoc} |
||
181 | */ |
||
182 | public function refreshUser(UserInterface $user) |
||
200 | |||
201 | /** |
||
202 | * {@inheritdoc} |
||
203 | */ |
||
204 | public function supportsClass($class) |
||
208 | |||
209 | /** |
||
210 | * Search for, and return, the LDAP user by a specific attribute. |
||
211 | * |
||
212 | * @param string $attribute |
||
213 | * @param string $value |
||
214 | * @return LdapObject |
||
215 | */ |
||
216 | protected function getLdapUser($attribute, $value) |
||
233 | |||
234 | /** |
||
235 | * Get all the attributes that should be selected for when querying LDAP. |
||
236 | * |
||
237 | * @return array |
||
238 | */ |
||
239 | protected function getAttributesToSelect() |
||
246 | |||
247 | /** |
||
248 | * @param LdapObject $ldapObject |
||
249 | * @return LdapUserInterface |
||
250 | */ |
||
251 | protected function constructUserClass(LdapObject $ldapObject) |
||
279 | } |
||
280 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: