Table of Contents
Usage
Include the ldap class
require_once '[APPROOT]/classes/ldap.class.php';
Create a config with connection data
As an example I create a hash named $aConfig and save it as “inc_config.php”.
$aConfig=[
...
'ldap' => [
'server' => 'ldaps://ldap.example.com',
'port' => 636,
'DnLdapUser' => 'cn=Lookup,ou=Service,dc=some,dc=example.com',
'PwLdapUser' => 'PasswordOfLookupUser',
// node where to find users that are allowed to login
'DnUserNode' => 'ou=People,dc=some,dc=example.com',
// node where to find my app
'DnAppNode' => 'cn=MyApp,dc=some,dc=example.com',
'debugLevel' => 0,
],
...
];
Example: verify login data
require_once('inc_config.php');
require_once '[APPROOT]/classes/ldap.class.php';
oLdap=new imlldap($aConfig['ldap']);
// set values from $_FORM or $_POST data of your login form here
// The variable $bAuthenticated is true if authentication of the user was successful.
$bAuthenticated=oLdap->verifyPassword($sUser, $sPassword);