PHP code example of ltb-project / ldap

1. Go to this page and download the library: Download ltb-project/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/ */

    

ltb-project / ldap example snippets




$ldap_url = "ldap://ldap.example.com";
$ldap_starttls = false;
$ldap_binddn = "cn=admin,dc=example,dc=com";
$ldap_bindpw = "secret";
$ldap_network_timeout = 3;
$ldap_user_base = "ou=people,dc=example,dc=com";
$ldap_size_limit = -1;
$ldap_krb5ccname = null;
$ldap_page_size = 1000;

$ldapInstance = new \Ltb\Ldap(
        $ldap_url,
        $ldap_starttls,
        $ldap_binddn,
        $ldap_bindpw,
        $ldap_network_timeout,
        $ldap_user_base,
        $ldap_size_limit,
        $ldap_krb5ccname,
        $ldap_page_size
);

$ldap_connection = $ldapInstance->connect();

$ldap = $ldap_connection[0];
$result = $ldap_connection[1];

if (!$result) {
    error_log("Unable to connect to $ldap_url");
    exit 1;
}