blob: e10da3740f4fc5bbf02dfe1c90dab063ca0a1857 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Adldap\Auth;
4
5use Adldap\Connections\ConnectionInterface;
6use Adldap\Configuration\DomainConfiguration;
7
8interface GuardInterface
9{
10 /**
11 * Constructor.
12 *
13 * @param ConnectionInterface $connection
14 * @param DomainConfiguration $configuration
15 */
16 public function __construct(ConnectionInterface $connection, DomainConfiguration $configuration);
17
18 /**
19 * Authenticates a user using the specified credentials.
20 *
21 * @param string $username The users LDAP username.
22 * @param string $password The users LDAP password.
23 * @param bool $bindAsUser Whether or not to bind as the user.
24 *
25 * @throws \Adldap\Auth\BindException When re-binding to your LDAP server fails.
26 * @throws \Adldap\Auth\UsernameRequiredException When username is empty.
27 * @throws \Adldap\Auth\PasswordRequiredException When password is empty.
28 *
29 * @return bool
30 */
31 public function attempt($username, $password, $bindAsUser = false);
32
33 /**
34 * Binds to the current connection using the inserted credentials.
35 *
36 * @param string|null $username
37 * @param string|null $password
38 *
39 * @throws \Adldap\Auth\BindException If binding to the LDAP server fails.
40 * @throws \Adldap\Connections\ConnectionException If upgrading the connection to TLS fails
41 *
42 * @return void
43 */
44 public function bind($username = null, $password = null);
45
46 /**
47 * Binds to the current LDAP server using the
48 * configuration administrator credentials.
49 *
50 * @throws \Adldap\Auth\BindException When binding as your administrator account fails.
51 *
52 * @return void
53 */
54 public function bindAsAdministrator();
55}