1. Go to this page and download the library: Download golenishev/yii2-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/ */
golenishev / yii2-ldap example snippets
return [
//....
'components' => [
'ldap' => [
'class' => 'chrmorandi\ldap\Connection',
// Mandatory Configuration Options
'dc' => [
'192.168.1.1',
'ad.com'
],
'baseDn' => 'dc=ad,dc=com',
'username' => '[email protected]',
'password' => 'password',
// Optional Configuration Options
'port' => 389,
'followReferrals' => false,
'useTLS' => true,
// Change pageSize (e.g. to 1000) if you are getting the following message
// with large result sets:
// ldap_search(): Partial search results returned: Sizelimit exceeded
'pageSize' => -1,
],
]
];
try {
if (Yii::$app->ldap->auth($this->username, $password)) {
// Credentials were correct.
} else {
// Credentials were incorrect.
}
} catch (Exception $e) {
// error
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.