Documentation

GRIS_LDAP
in package

Class for ldap authentification

With this class users can be authenticicated via ldap oder active directory

PHP version 7

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany

Tags
copyright

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences

link

GESIS Leibniz Institute for the Social Sciences

since
1

File available since Release 1.0

version
1.0
author

Holger Heuser holger.heuser@gesis.org

Table of Contents

settings_group  = "ldap"
The constant for the settings group
$classname  : object
The name of the class
$basedn  : string
The base dn for ldap
$error  : string
The current ldap error (if one appeared)
$ldap_data  : array<string|int, mixed>
The LDAP data of a given user
$ldapconnection  : object
The ldap connection
$ldaphost  : string
The ldap host
$mapping  : array<string|int, mixed>
The mapping for the LDAP data
$settings  : object
The object for settings
$state  : object
The object for state
__construct()  : mixed
The class constructor
connect()  : bool
Connects to ldapserver and checks username and pass
get_error()  : string
Returns the current ldap error
get_ldap_data()  : string
Returns the ldap entry according to a given key
get_new_users()  : string
Find new users in LDAP/AD
get_su_data()  : array<string|int, mixed>
Get data for a switch user
get_user_data_by_guid()  : array<string|int, mixed>
Get data of a user by a given guid
is_user()  : bool
Check if a user is member of the current ldap or AD
search()  : mixed
Returns the distinguished name of a given user or # if user was not found in ldap
format_entry()  : mixed
Formats an LDAP entry
ldap_filter()  : bool
Checks if the term contains a filter expression

Constants

settings_group

The constant for the settings group

public mixed settings_group = "ldap"

Properties

$classname

The name of the class

protected object $classname = NULL
Tags
access

private

$basedn

The base dn for ldap

private string $basedn
Tags
access

private

$error

The current ldap error (if one appeared)

private string $error = ""
Tags
access

private

$ldap_data

The LDAP data of a given user

private array<string|int, mixed> $ldap_data = array()
Tags
access

private

$ldapconnection

The ldap connection

private object $ldapconnection
Tags
access

private

$ldaphost

The ldap host

private string $ldaphost
Tags
access

private

$mapping

The mapping for the LDAP data

private array<string|int, mixed> $mapping = array()
Tags
access

private

$settings

The object for settings

private object $settings
Tags
access

private

$state

The object for state

private object $state
Tags
access

private

Methods

__construct()

The class constructor

public __construct() : mixed

Initializes the ldap setting

Return values
mixed

connect()

Connects to ldapserver and checks username and pass

public connect([string $username = null ][, string $password = null ][, bool $test = false ]) : bool
Parameters
$username : string = null

The username from the login form

$password : string = null

The password from the login form

$test : bool = false

Only check if user exists

Return values
bool

The bind success (if no username or pass is given, only the reader account is bound)

get_error()

Returns the current ldap error

public get_error() : string
Return values
string

The ldap error

get_ldap_data()

Returns the ldap entry according to a given key

public get_ldap_data([string $key = null ]) : string
Parameters
$key : string = null

The key for the ldap attribute

Return values
string

The ldap entry

get_new_users()

Find new users in LDAP/AD

public get_new_users() : string
Return values
string

The ldap entry

get_su_data()

Get data for a switch user

public get_su_data(int $person_id) : array<string|int, mixed>
Parameters
$person_id : int

The person ID

Return values
array<string|int, mixed>

Returns the array with data for update the basedata

get_user_data_by_guid()

Get data of a user by a given guid

public get_user_data_by_guid(int $mail) : array<string|int, mixed>
Parameters
$mail : int

The mail adress of the person

Return values
array<string|int, mixed>

Returns the array with data of the person

is_user()

Check if a user is member of the current ldap or AD

public is_user(string $username) : bool
Parameters
$username : string

The username

Return values
bool

Returns true for yes and false for no

Returns the distinguished name of a given user or # if user was not found in ldap

public search([string $search = NULL ][, string $dn = NULL ]) : mixed
Parameters
$search : string = NULL

the search term

$dn : string = NULL

the distinguished anme

Return values
mixed

The data as an array or (boolean) true or false for single entries (data is then stored in the $this->ldap_data)

format_entry()

Formats an LDAP entry

private format_entry(array<string|int, mixed> $entry[, booelan $return = false ]) : mixed
Parameters
$entry : array<string|int, mixed>

The LDPA entry

$return : booelan = false

Returns the whole array if true. If false only dn is returned and data (single person) is stored in the object ($this->ldap_data)

Return values
mixed

The dn ("#" if no dn available) or the formatted entry

ldap_filter()

Checks if the term contains a filter expression

private ldap_filter(string $term) : bool
Parameters
$term : string

the username from the login form

Return values
bool

Returns true if expression is in term

Search results