Getting Started

First, create the LdapWrapper object. Then, create the LdapSearch object that can be used to search the directory.

 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
<?php
use Vespula\Ldap\LdapWrapper;
use Vespula\Ldap\LdapSearch;

$wrapper = new LdapWrapper;

$uri = 'ldap.mycompany.org';

// basedn is the dn used for searches
// binddn is the dn to bind to as a user
// bindpw is the bind password for the user.
// See ldap_bind() in the PHP manual

$bindOptions = [
    'basedn'=>'OU=users,OU=mycompany,OU=org',
    'binddn'=>'CN=juser,OU=users,OU=mycompany,OU=org',
    'bindpw'=>'********'
];

$ldapOptions = [
    LDAP_OPT_PROTOCOL_VERSION=>3,
    LDAP_OPT_REFERRALS=>0
];

// 389 is the default
$port = 389;

$ldap = new LdapSearch($wrapper, $uri, $bindOptions, $ldapOptions, $port);