Downloads
Stars
Version
Provide simple wrapping class to LDAP services.
composer require daemon144key/laravel-simple-ldap
<?php
return [
// ...
'providers' => [
// ...
TuxDaemon\LaravelSimpleLdap\LaravelSimpleLdapServiceProvider::class
],
'aliases' => [
// ...
'LDAP' => TuxDaemon\LaravelSimpleLdap\Services\Facades\LdapService::class,
],
];
php artisan optimize
SIMPLE_LDAP_HOST=
SIMPLE_LDAP_PORT=389
SIMPLE_LDAP_BASE_DN=
SIMPLE_LDAP_PASSWORD=
SIMPLE_LDAP_USER_RDN=
or
php artisan vendor:publish --tag=laravel-simple-ldap-config
then edit in config/laravel_simple_ldap.php
LDAP::connnect()
LDAP::bindUser($optionalUserRDN = "");
LDAP::search ($filter, $extendedBaseDN = "");
LDAP::add($rdn, $data);
LDAP::modify($rdn, $data);
LDAP::modifyReplace($rdn, $data);
LDAP::delete($rdn);
LDAP::close();
<?php
// .....
if (LDAP::connnect())
{
// Bind to LDAP
$bind = LDAP::bindUser();
// Search in LDAP
$inputFilter["gender"] = "male";
$result = LDAP::search ($inputFilter, "ou=people");
info($result);
// Add to LDAP
$data["objectclass"][0] = "orgPerson";
$data["objectclass"][1] = "orgEmail";
$data["objectclass"][2] = "orgProxyClient";
$data["userpassword"] = 'secret';
$data["usingstatus"] = "TRUE";
$data["gender"] = "male";
$data["homedir"] = "/home/someperson";
$addResult = LDAP::add("orgAccountID=someperson,ou=people", $data);
info($addResult);
// Modify Data in LDAP
$data["gender"] = "female";
$modifyResult = LDAP::modify("orgAccountID=someperson,ou=people", $data);
info($modifyResult);
// Delete Data in LDAP
$deleteResult = LDAP::delete("orgAccountID=someperson,ou=people");
info($deleteResult);
// Close Connection in LDAP
LDAP::close();
} else {
return "Can't connect to LDAP!";
}
// .....
The Laravel framework is open-sourced software licensed under the MIT license