-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathldap-server.php
More file actions
34 lines (27 loc) · 1.01 KB
/
Copy pathldap-server.php
File metadata and controls
34 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require __DIR__ . '/../vendor/autoload.php';
use Fneufneu\React\Ldap\Ldap;
use Fneufneu\React\Ldap\Ber;
use Fneufneu\React\Ldap\Response;
$loop = React\EventLoop\Factory::create();
$server = new Fneufneu\React\Ldap\Server(function ($client) {
echo "new client" . PHP_EOL;
$client->on('bind', function ($infos) use ($client) {
echo "new bindRequest: " . json_encode($infos) . PHP_EOL;
$resp = new Response($infos['messageID'], Ldap::bindResponse);
$client->write($resp);
});
$client->on('unbind', function ($infos) use ($client) {
$client->end();
});
$client->on('search', function ($infos) use ($client) {
echo "new search: " . json_encode($infos) . PHP_EOL;
$client->write(new Response($infos['messageID'], Ldap::searchResDone, 0, '', ''));
});
$client->on('add', function ($infos) use ($client) {
$client->write(new Response($infos['messageID'], Ldap::addResponse, 1, '', 'not implemented'));
});
});
$socket = new React\Socket\Server('0.0.0.0:33389', $loop);
$server->listen($socket);
$loop->run();