2017 © Pedro Peláez
 

library laravel-simple-ldap

Simple class to wrapping LDAP services.

image

daemon144key/laravel-simple-ldap

Simple class to wrapping LDAP services.

  • Wednesday, July 4, 2018
  • by daemon144key
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel Simple LDAP

Description

Provide simple wrapping class to LDAP services., (*1)

Setup / Initiation

  • Install packages
composer require daemon144key/laravel-simple-ldap
  • Add to app/config.php
<?php
return [
    // ...
    'providers' => [
        // ...
        TuxDaemon\LaravelSimpleLdap\LaravelSimpleLdapServiceProvider::class
    ],
    'aliases' => [
        // ...
        'LDAP'      => TuxDaemon\LaravelSimpleLdap\Services\Facades\LdapService::class,
    ],
];
  • Optimize
php artisan optimize
  • Set up config with default environment variabel key (LDAP Server hostname / ip-address, LDAP Server Port, Base Distinguished Name/DN, and administrator level user Relative-DN & password) or publish config for further configuration
SIMPLE_LDAP_HOST=
SIMPLE_LDAP_PORT=389
SIMPLE_LDAP_BASE_DN=
SIMPLE_LDAP_PASSWORD=
SIMPLE_LDAP_USER_RDN=

or, (*2)

php artisan vendor:publish --tag=laravel-simple-ldap-config

then edit in config/laravel_simple_ldap.php, (*3)

Services Usages

  • First Initiate Connection
LDAP::connnect()
  • Binding Users
LDAP::bindUser($optionalUserRDN = "");
  • Search based on filters
LDAP::search ($filter, $extendedBaseDN = ""); 
  • Add Record
LDAP::add($rdn, $data);
  • Modify Record (object level)
LDAP::modify($rdn, $data);
  • Modify Record (object attribute level)
LDAP::modifyReplace($rdn, $data);
  • Delete Record
LDAP::delete($rdn);
  • Finally Close Connection
LDAP::close();

Sample Usages

<?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!";
    }
    // .....

License

The Laravel framework is open-sourced software licensed under the MIT license, (*4)

The Versions

04/07 2018

dev-master

9999999-dev

Simple class to wrapping LDAP services.

  Sources   Download

MIT

The Requires

 

by Joel Hutasoit

04/07 2018

0.1.5

0.1.5.0

Simple class to wrapping LDAP services.

  Sources   Download

MIT

The Requires

 

by Joel Hutasoit