2017 © Pedro Peláez
 

library ldap

Simple lib to authenticate trough ldap with some extra features

image

erwin32/ldap

Simple lib to authenticate trough ldap with some extra features

  • Friday, January 26, 2018
  • by Erwin32
  • Repository
  • 1 Watchers
  • 1 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

simple LDAP auth

class for very simple ldap auth cheks if user exists and if he/she is in given group., (*1)

Usage:

$ composer require erwin32/ldap

Init sample, (*2)

    // Active Directory server
    $ldap_host = "123.123.123.123";//IP adress or url

    // Active Directory DN
    $ldap_dn = 'DC=domain,DC=com';//domain in this example is used "domain.com"

    // Active Directory user group
    $ldap_user_group = "Group Name";

    // Active Directory manager group
    $ldap_manager_group = "Admins";

    // Domain, for purposes of constructing $user
    $ldap_usr_dom = "@domain.com";

    //class inicialization
    $ldap=new \LDAP\auth($ldap_host, $ldap_dn, $ldap_user_group, $ldap_manager_group, $ldap_usr_dom);

For auth use like this(expects inicialized class in $ldap), (*3)

first argument is username second is passoword, (*4)

    try {
        $ldap->authenticate($user, $pass);
    } catch (Exception $exc) {
        $msg=$exc->getMessage();
        $code=$exc->getCode();

        //this is how we can determine if user dont have corect group but exist on LDAP
        if($ldap::ERROR_WRONG_USER_GROUP==$code){
            //custom handling
        }
    }

Thumbnail img retrival example, (*5)

    try {
        $ldap->userInit($user, $pass);
        //we can display it like this
        echo '<img src="'.$ldap->getLDAPimg().'">';

    } catch (Exception $exc) {
        $msg=$exc->getMessage();
        $code=$exc->getCode();

        //react to problems
    }

Exeptions Error codes, (*6)

    $ldap::ERROR_WRONG_USER_GROUP

    $ldap::ERROR_CANT_AUTH

    $ldap::ERROR_CANT_SEARCH

    $ldap::ERROR_IMG_DECODE

The Versions

26/01 2018

dev-master

9999999-dev

Simple lib to authenticate trough ldap with some extra features

  Sources   Download

GNU2 GPL-2.0-only

by Petr Palas

26/01 2018

1.3

1.3.0.0

Simple lib to authenticate trough ldap with some extra features

  Sources   Download

GPL-2.0-only

by Petr Palas

19/12 2013

v1.2

1.2.0.0

Simple lib to authenticate trough ldap with some extra features

  Sources   Download

GNU2

by Petr Palas

04/12 2013

v1.1

1.1.0.0

Simple lib to authenticate trough ldap with some extra features

  Sources   Download

GNU2

by Petr Palas

21/11 2013

v1.0

1.0.0.0

Simple lib to authenticate trough ldap with some extra features

  Sources   Download

GNU2

by Petr Palas