1 | <?php |
||
27 | trait LdapAuthenticationTrait |
||
28 | { |
||
29 | /** |
||
30 | * @var LdapManager |
||
31 | */ |
||
32 | protected $ldap; |
||
33 | |||
34 | /** |
||
35 | * @var LdapUserProvider |
||
36 | */ |
||
37 | protected $ldapUserProvider; |
||
38 | |||
39 | /** |
||
40 | * The logic for determining the username/DN to bind with is as follows: |
||
41 | * |
||
42 | * 1. Always prefer a DN from a default user from the LDAP user provider, or LdapObject instance from LdapTools |
||
43 | * 2. If it wasn't a LdapObject and no attribute was explicitly set to query LDAP for, use the UserInterface username |
||
44 | * 3. Query LDAP using a specific attribute for a user with the specified username, return the DN. |
||
45 | * |
||
46 | * @param UserInterface $user |
||
47 | * @param string|null $queryAttribute |
||
48 | * @return string |
||
49 | */ |
||
50 | protected function getBindUsername(UserInterface $user, $queryAttribute) |
||
63 | |||
64 | /** |
||
65 | * If no LDAP credentials are in the config then attempt to use the user supplied credentials from the login. But |
||
66 | * only if we are using the LdapUserProvider. |
||
67 | * |
||
68 | * @param string $username |
||
69 | * @param string $password |
||
70 | * @param UserProviderInterface $userProvider |
||
71 | */ |
||
72 | protected function setLdapCredentialsIfNeeded($username, $password, UserProviderInterface $userProvider) |
||
88 | |||
89 | /** |
||
90 | * If the domain needs to a different context for the request, then switch it. |
||
91 | * |
||
92 | * @param string|null $domain |
||
93 | */ |
||
94 | protected function switchDomainIfNeeded($domain) |
||
100 | |||
101 | /** |
||
102 | * If the passed domain is not the current context, then switch back to it. |
||
103 | * |
||
104 | * @param string $domain |
||
105 | */ |
||
106 | protected function switchDomainBackIfNeeded($domain) |
||
112 | |||
113 | /** |
||
114 | * Determine whether or not the exception should be masked with a BadCredentials or not. |
||
115 | * |
||
116 | * @param \Exception $e |
||
117 | * @param bool $hideUserNotFoundExceptions |
||
118 | * @throws \Exception |
||
119 | */ |
||
120 | protected function hideOrThrow(\Exception $e, $hideUserNotFoundExceptions) |
||
134 | } |
||
135 |