1<?php
2
3/**
4 * This file is part of the FreeDSx LDAP package.
5 *
6 * (c) Chad Sikorra <Chad.Sikorra@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace FreeDSx\Ldap\Server\RequestHandler;
13
14use FreeDSx\Ldap\Entry\Entries;
15use FreeDSx\Ldap\Exception\OperationException;
16use FreeDSx\Ldap\Operation\Request\AddRequest;
17use FreeDSx\Ldap\Operation\Request\CompareRequest;
18use FreeDSx\Ldap\Operation\Request\DeleteRequest;
19use FreeDSx\Ldap\Operation\Request\ExtendedRequest;
20use FreeDSx\Ldap\Operation\Request\ModifyDnRequest;
21use FreeDSx\Ldap\Operation\Request\ModifyRequest;
22use FreeDSx\Ldap\Operation\Request\SearchRequest;
23use FreeDSx\Ldap\Server\RequestContext;
24
25/**
26 * This allows the LDAP server to run, but rejects everything. You can extend and selectively override specific request
27 * types to support what you want.
28 *
29 * @author Chad Sikorra <Chad.Sikorra@gmail.com>
30 */
31class GenericRequestHandler implements RequestHandlerInterface
32{
33    /**
34     * {@inheritdoc}
35     */
36    public function add(RequestContext $context, AddRequest $add): void
37    {
38        throw new OperationException('The add operation is not supported.');
39    }
40
41    /**
42     * @return false
43     */
44    public function bind(string $username, string $password): bool
45    {
46        return false;
47    }
48
49    /**
50     * {@inheritdoc}
51     */
52    public function compare(RequestContext $context, CompareRequest $compare): bool
53    {
54        throw new OperationException('The compare operation is not supported.');
55    }
56
57    /**
58     * {@inheritdoc}
59     */
60    public function delete(RequestContext $context, DeleteRequest $delete): void
61    {
62        throw new OperationException('The delete operation is not supported.');
63    }
64
65    /**
66     * {@inheritdoc}
67     */
68    public function extended(RequestContext $context, ExtendedRequest $extended): void
69    {
70        throw new OperationException(sprintf('The extended operation %s is not supported.', $extended->getName()));
71    }
72
73    /**
74     * {@inheritdoc}
75     */
76    public function modify(RequestContext $context, ModifyRequest $modify): void
77    {
78        throw new OperationException('The modify operation is not supported.');
79    }
80
81    /**
82     * {@inheritdoc}
83     */
84    public function modifyDn(RequestContext $context, ModifyDnRequest $modifyDn): void
85    {
86        throw new OperationException('The modify dn operation is not supported.');
87    }
88
89    /**
90     * {@inheritdoc}
91     */
92    public function search(RequestContext $context, SearchRequest $search): Entries
93    {
94        throw new OperationException('The search operation is not supported.');
95    }
96}
97