1 | <?php |
---|
2 | /***********************************************************************************\ |
---|
3 | * eGroupWare - Contacts Center * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Written by: * |
---|
6 | * - Mário César Kolling <mario.kolling@serpro.gov.br> * |
---|
7 | * Based on: * |
---|
8 | * - Multi-threading strategies in PHP from * |
---|
9 | * http://www.alternateinterior.com/2007/05/multi-threading-strategies-in-php.html * |
---|
10 | * ----------------------------------------------------------------------------------* |
---|
11 | * This program is free software; you can redistribute it and/or modify it * |
---|
12 | * under the terms of the GNU General Public License as published by the * |
---|
13 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
14 | * option) any later version. * |
---|
15 | \***********************************************************************************/ |
---|
16 | |
---|
17 | require_once('class.ThreadInstance.inc.php'); |
---|
18 | |
---|
19 | /* |
---|
20 | * This is the Main Class that will be called in a new php process to test a bind in an ldap source |
---|
21 | */ |
---|
22 | |
---|
23 | class ldap_assync extends ThreadInstance |
---|
24 | { |
---|
25 | |
---|
26 | var $ldap; |
---|
27 | var $account; |
---|
28 | var $password; |
---|
29 | var $host; |
---|
30 | |
---|
31 | function ldap_assync($host, $account = false, $password = false) |
---|
32 | { |
---|
33 | $this->host = $host; |
---|
34 | $this->account = $account; |
---|
35 | $this->password = $password; |
---|
36 | $this->ldap = ldap_connect($this->host); |
---|
37 | |
---|
38 | $this->setup(); |
---|
39 | $this->go(); |
---|
40 | } |
---|
41 | |
---|
42 | function go () |
---|
43 | { |
---|
44 | if (ldap_bind($this->ldap, $this->account, $this->password)) |
---|
45 | { |
---|
46 | $this->response("ok", ldap_error($this->ldap)); |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | $this->response("no", ldap_error($this->ldap)); |
---|
51 | } |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | } |
---|
56 | |
---|
57 | /* |
---|
58 | * Here is where we instantiate the new class. All the parameters are passed to the php process |
---|
59 | * as environment variables |
---|
60 | */ |
---|
61 | $search_ldap = new ldap_assync($_ENV['host'], $_ENV['account'], $_ENV['password']); |
---|
62 | |
---|
63 | ?> |
---|