PHP code example of apung / ldap

1. Go to this page and download the library: Download apung/ldap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

apung / ldap example snippets


'providers' => array(
    ....
    'Apung\Ldap\LdapServiceProvider',
    ....
),

$options = array(
            'host'=>'ldap.example.com',
            'port'=>389,
            'base_dn'=>'dc=example,dc=com',
            'bind_rdn'=>'cn=admin,dc=example,dc=com',
            'bind_pw'=>'ManagerPassword!!!'
        );

$ldap = new \Apung\Ldap\Ldap($options);

//search person (which have uid) inside ou=people,dc=exampe,dc=com
$select = $ldap->select('uid')->from('ou=people,dc=example,dc=com')->where(array('uid'=>'*'))->get();

//like above, but return DN
$select = $ldap->select('uid')->from('ou=people,dc=example,dc=com')->where(array('uid'=>'*'))->withdn()->get();

//like above, but return all attributes (inside select statement)
$select = $ldap->select(array('uid','givenname'))->from('ou=people,dc=example,dc=com')->where(array('uid'=>'*'))->getAll();