PHP Class AuthLDAP, glpi

Inheritance: extends AuthPluginBase
Mostrar archivo Open project: glpi-project/glpi Class Usage Examples

Public Properties

Property Type Description
$dohistory From CommonDBTM
$rightname

Public Methods

Method Description
addTimestampRestrictions ( $begin_date, $end_date )
canCreate ( )
canPurge ( )
cleanDBonPurge ( )
connect ( ) Open LDAP connexion to current serveur
connectToServer ( $host, $port, $login = "", $password = "", $use_tls = false, $deref_options ) : link Connect to a LDAP serveur
date2ldapTimeStamp ( $date ) : ldap Converts a Unix timestamp to an LDAP timestamps
defineTabs ( $options = [] )
displayLdapFilter ( $target, $users = true ) : nothing Display LDAP filter
displaySizeLimitWarning ( $limitexceeded = false )
displayTabContentForItem ( CommonGLPI $item, $tabnum = 1, $withtemplate )
dnExistsInLdap ( $ldap_infos, $user_dn ) : false Check if a user DN exists in a ldap user search result
dropdownGroupSearchType ( array $options )
dropdownUserDeletedActions ( $value )
getAllGroups ( $auths_id, $filter, $filter2, $entity, &$limitexceeded, $order = 'DESC' ) : array Get all LDAP groups from a ldap server which are not already in an entity
getAllReplicateForAMaster ( $master_id ) : array Get all replicate servers for a master one
getAllUsers ( $options = [], &$results, &$limitexceeded ) : array Get the list of LDAP users to add/synchronize
getDefault ( )
getGroupByDn ( $ds, $group_dn ) : group Get infos for groups
getGroupCNByDn ( $ldap_connection, $group_dn ) : the Get the group's cn by giving his DN
getGroupSearchTypeName ( $val = NULL ) : array Get the possible value for contract alert
getGroupsFromLDAP ( $ldap_connection, $config_ldap, $filter, $search_in_groups = true, $groups = [], &$limitexceeded )
getLdapServers ( )
getNumberOfServers ( )
getObjectByDn ( $ds, $condition, $dn, $attrs = [], $clean = true ) Get an object from LDAP by giving his DN
getSearchOptions ( )
getServersWithImportByEmailActive ( ) : array Return all the ldap servers where email field is configured
getSpecificValueToDisplay ( $field, $values, array $options = [] )
getSpecificValueToSelect ( $field, $name = '', $values = '', array $options = [] )
getSyncFields ( array $authtype_array ) : array Get LDAP fields to sync to GLPI data from a glpi_authldaps array
getTabNameForItem ( CommonGLPI $item, $withtemplate )
getTypeName ( $nb )
getUserByDn ( $ds, $user_dn, $attrs, $clean = true )
get_entries_clean ( $link, $result ) : an Get ldap query results and clean them at the same time
importUserFromServers ( $options = [] ) Import a user from ldap Check all the directories. When the user is found, then import it
isLdapPageSizeAvailable ( $config_ldap, $check_config_value = true ) Check if ldap results can be paged or not This functionnality is available for PHP 5.4 and higer
ldapAuth ( $auth, $login, $password, $ldap_method, $user_dn ) : identification Authentify a user by checking a specific directory
ldapChooseDirectory ( $target ) : nothing Form to choose a ldap server
ldapImportGroup ( $group_dn, $options = [] ) : nothing Converts an array of parameters into a query string to be appended to a URL.
ldapImportUserByServerId ( $params = [], $action, $ldap_server, $display = false ) : array Import a user from a specific ldap server
ldapStamp2UnixStamp ( $ldapstamp, $ldap_time_offset ) : unix Converts LDAP timestamps over to Unix timestamps
local_cmp ( $a, $b )
manageValuesInSession ( $options = [], $delete = false )
post_addItem ( )
post_getEmpty ( )
post_updateItem ( $history = 1 )
preconfig ( $type ) : nothing Preconfig datas for standard system
prepareInputForAdd ( $input )
prepareInputForUpdate ( $input )
processMassiveActionsForOneItemtype ( MassiveAction $ma, CommonDBTM $item, array $ids )
searchForUsers ( $ds, $values, $filter, $attrs, &$limitexceeded, &$user_infos, &$ldap_users, $config_ldap )
searchUser ( AuthLDAP $authldap )
searchUserDn ( $ds, $options = [] ) : dn Get dn for a user
showDateRestrictionForm ( $options = [] )
showForm ( $ID, $options = [] ) : Nothing Print the auth ldap form
showFormAdvancedConfig ( )
showFormEntityConfig ( )
showFormGroupsConfig ( )
showFormReplicatesConfig ( )
showFormTestLDAP ( )
showFormUserConfig ( )
showLdapGroups ( $target, $start, $sync, $filter = '', $filter2 = '', $entity, $order = 'DESC' ) : nothing Show LDAP groups to add or synchronise in an entity
showLdapUsers ( ) : nothing Show LDAP users to add or synchronise
showSystemInformations ( $width )
showUserImportForm ( AuthLDAP $authldap )
testLDAPConnection ( $auths_id, $replicate_id ) : boolean Test a LDAP connection
tryLdapAuth ( $auth, $login, $password, $auths_id, $user_dn = false, $break = true ) : identification Try to authentify a user by checking all the directories
tryToConnectToServer ( $ldap_method, $login, $password ) : link Try to connect to a ldap server
unsetUndisclosedFields ( &$fields )
useAuthLdap ( ) : boolean Is the LDAP authentication used ?

Private Methods

Method Description
buildLdapFilter ( AuthLdap $authldap )

Method Details

addTimestampRestrictions() static public method

static public addTimestampRestrictions ( $begin_date, $end_date )
$begin_date datetime begin date to search (NULL if not take into account)
$end_date datetime end date to search (NULL if not take into account)

canCreate() static public method

static public canCreate ( )

canPurge() static public method

static public canPurge ( )

cleanDBonPurge() public method

public cleanDBonPurge ( )

connect() public method

Open LDAP connexion to current serveur
public connect ( )

connectToServer() static public method

Connect to a LDAP serveur
static public connectToServer ( $host, $port, $login = "", $password = "", $use_tls = false, $deref_options ) : link
$host LDAP host to connect
$port port to use
$login login to use (default '')
$password password to use (default '')
$use_tls use a tls connection ? (false by default)
$deref_options deref options used
return link to the LDAP server : false if connection failed

date2ldapTimeStamp() static public method

Converts a Unix timestamp to an LDAP timestamps
static public date2ldapTimeStamp ( $date ) : ldap
$date datetime
return ldap timestamp

defineTabs() public method

public defineTabs ( $options = [] )

displayLdapFilter() static public method

Display LDAP filter
static public displayLdapFilter ( $target, $users = true ) : nothing
$target target for the form
$users boolean for user ? (true by default)
return nothing

displaySizeLimitWarning() static public method

static public displaySizeLimitWarning ( $limitexceeded = false )
$limitexceeded (false by default)

displayTabContentForItem() static public method

static public displayTabContentForItem ( CommonGLPI $item, $tabnum = 1, $withtemplate )
$item CommonGLPI

dnExistsInLdap() static public method

Check if a user DN exists in a ldap user search result
static public dnExistsInLdap ( $ldap_infos, $user_dn ) : false
$ldap_infos ldap user search result
$user_dn user dn to look for
return false if the user dn doesn't exist, user ldap infos otherwise

dropdownGroupSearchType() static public method

static public dropdownGroupSearchType ( array $options )
$options array array

dropdownUserDeletedActions() static public method

static public dropdownUserDeletedActions ( $value )
$value (default 0)

getAllGroups() static public method

Get all LDAP groups from a ldap server which are not already in an entity
static public getAllGroups ( $auths_id, $filter, $filter2, $entity, &$limitexceeded, $order = 'DESC' ) : array
$auths_id ID of the server to use
$filter ldap filter to use
$filter2 second ldap filter to use if needed
$entity entity to search
$limitexceeded
$order order to use (default DESC)
return array of the groups

getAllReplicateForAMaster() static public method

Get all replicate servers for a master one
static public getAllReplicateForAMaster ( $master_id ) : array
$master_id : master ldap server ID
return array of the replicate servers

getAllUsers() static public method

Get the list of LDAP users to add/synchronize
static public getAllUsers ( $options = [], &$results, &$limitexceeded ) : array
$options array of possible options: - authldaps_id ID of the server to use - mode user to synchronise or add ? - ldap_filter ldap filter to use - basedn force basedn (default authldaps_id one) - order display order - begin_date begin date to time limit - end_date end date to time limit - script true if called by an external script
return array of the user

getDefault() static public method

static public getDefault ( )

getGroupByDn() static public method

Get infos for groups
static public getGroupByDn ( $ds, $group_dn ) : group
$ds LDAP link
$group_dn dn of the group
return group infos if found, else false

getGroupCNByDn() static public method

Get the group's cn by giving his DN
static public getGroupCNByDn ( $ldap_connection, $group_dn ) : the
$ldap_connection ldap connection to use
$group_dn the group's dn
return the group cn

getGroupSearchTypeName() static public method

Get the possible value for contract alert
static public getGroupSearchTypeName ( $val = NULL ) : array
$val if not set, ask for all values, else for 1 value (default NULL)
return array or string

getGroupsFromLDAP() static public method

static public getGroupsFromLDAP ( $ldap_connection, $config_ldap, $filter, $search_in_groups = true, $groups = [], &$limitexceeded )
$ldap_connection
$config_ldap
$filter
$search_in_groups (true by default)
$groups array
$limitexceeded

getLdapServers() static public method

static public getLdapServers ( )

getNumberOfServers() static public method

static public getNumberOfServers ( )

getObjectByDn() static public method

Get an object from LDAP by giving his DN
static public getObjectByDn ( $ds, $condition, $dn, $attrs = [], $clean = true )
$dn string DN of the object
$clean (true by default)

getSearchOptions() public method

public getSearchOptions ( )

getServersWithImportByEmailActive() static public method

Return all the ldap servers where email field is configured
static public getServersWithImportByEmailActive ( ) : array
return array of LDAP server's ID

getSpecificValueToDisplay() static public method

static public getSpecificValueToDisplay ( $field, $values, array $options = [] )
$field
$values
$options array array

getSpecificValueToSelect() static public method

static public getSpecificValueToSelect ( $field, $name = '', $values = '', array $options = [] )
$field
$name (default '')
$values (default('')
$options array array

getSyncFields() static public method

Get LDAP fields to sync to GLPI data from a glpi_authldaps array
static public getSyncFields ( array $authtype_array ) : array
$authtype_array array array Authentication method config array (from table)
return array of "user table field name" => "config value"

getTabNameForItem() public method

public getTabNameForItem ( CommonGLPI $item, $withtemplate )
$item CommonGLPI

getTypeName() static public method

static public getTypeName ( $nb )

getUserByDn() static public method

static public getUserByDn ( $ds, $user_dn, $attrs, $clean = true )
$ds
$user_dn
$attrs
$clean (true by default)

get_entries_clean() static public method

Get ldap query results and clean them at the same time
static public get_entries_clean ( $link, $result ) : an
return an array which contains ldap query results

importUserFromServers() static public method

Import a user from ldap Check all the directories. When the user is found, then import it
static public importUserFromServers ( $options = [] )
$options array containing condition: array('name'=>'glpi') or array('email' => 'test at test.com')

isLdapPageSizeAvailable() static public method

Check if ldap results can be paged or not This functionnality is available for PHP 5.4 and higer
Since: 0.84 return true if maxPageSize can be used, false otherwise
static public isLdapPageSizeAvailable ( $config_ldap, $check_config_value = true )

ldapAuth() static public method

Authentify a user by checking a specific directory
static public ldapAuth ( $auth, $login, $password, $ldap_method, $user_dn ) : identification
$auth identification object
$login user login
$password user password
$ldap_method ldap_method array to use
$user_dn user LDAP DN if present
return identification object

ldapChooseDirectory() static public method

Form to choose a ldap server
static public ldapChooseDirectory ( $target ) : nothing
$target target page for the form
return nothing

ldapImportGroup() static public method

Converts an array of parameters into a query string to be appended to a URL.
static public ldapImportGroup ( $group_dn, $options = [] ) : nothing
$group_dn dn of the group to import
$options array for - authldaps_id - entities_id where group must to be imported - is_recursive
return nothing

ldapImportUserByServerId() static public method

Import a user from a specific ldap server
static public ldapImportUserByServerId ( $params = [], $action, $ldap_server, $display = false ) : array
$params array of parameters: method (IDENTIFIER_LOGIN or IDENTIFIER_EMAIL) + value
$action synchoronize (true) or import (false)
$ldap_server ID of the LDAP server to use
$display display message information on redirect (false by default)
return array with state, else false

ldapStamp2UnixStamp() static public method

Converts LDAP timestamps over to Unix timestamps
static public ldapStamp2UnixStamp ( $ldapstamp, $ldap_time_offset ) : unix
$ldapstamp LDAP timestamp
$ldap_time_offset time offset (default 0)
return unix timestamp

local_cmp() public method

public local_cmp ( $a, $b )

manageValuesInSession() static public method

static public manageValuesInSession ( $options = [], $delete = false )
$options array
$delete (false by default)

post_addItem() public method

public post_addItem ( )

post_getEmpty() public method

public post_getEmpty ( )

post_updateItem() public method

public post_updateItem ( $history = 1 )

preconfig() public method

Preconfig datas for standard system
public preconfig ( $type ) : nothing
$type type of standard system : AD
return nothing

prepareInputForAdd() public method

public prepareInputForAdd ( $input )

prepareInputForUpdate() public method

public prepareInputForUpdate ( $input )

processMassiveActionsForOneItemtype() static public method

See also: CommonDBTM::processMassiveActionsForOneItemtype()
static public processMassiveActionsForOneItemtype ( MassiveAction $ma, CommonDBTM $item, array $ids )
$ma MassiveAction
$item CommonDBTM
$ids array

searchForUsers() static public method

static public searchForUsers ( $ds, $values, $filter, $attrs, &$limitexceeded, &$user_infos, &$ldap_users, $config_ldap )

searchUser() static public method

static public searchUser ( AuthLDAP $authldap )
$authldap AuthLDAP AuthLDAP object

searchUserDn() static public method

Get dn for a user
static public searchUserDn ( $ds, $options = [] ) : dn
$ds LDAP link
$options array of possible options: - basedn : base dn used to search - login_field : attribute to store login - search_parameters array of search parameters - user_params array of parameters : method (IDENTIFIER_LOGIN or IDENTIFIER_EMAIL) + value - condition : ldap condition used
return dn of the user, else false

showDateRestrictionForm() static public method

static public showDateRestrictionForm ( $options = [] )
$options array

showForm() public method

Print the auth ldap form
public showForm ( $ID, $options = [] ) : Nothing
$ID integer ID of the item
$options array - target for the form
return Nothing (display)

showFormAdvancedConfig() public method

showFormEntityConfig() public method

showFormGroupsConfig() public method

showFormReplicatesConfig() public method

showFormTestLDAP() public method

public showFormTestLDAP ( )

showFormUserConfig() public method

public showFormUserConfig ( )

showLdapGroups() static public method

Show LDAP groups to add or synchronise in an entity
static public showLdapGroups ( $target, $start, $sync, $filter = '', $filter2 = '', $entity, $order = 'DESC' ) : nothing
$target target page for the form
$start where to start the list
$sync synchronise or add ? (default 0)
$filter ldap filter to use (default '')
$filter2 second ldap filter to use (which case ?) (default '')
$entity working entity
$order display order (default DESC)
return nothing

showLdapUsers() static public method

Show LDAP users to add or synchronise
static public showLdapUsers ( ) : nothing
return nothing

showSystemInformations() public method

public showSystemInformations ( $width )
$width

showUserImportForm() static public method

static public showUserImportForm ( AuthLDAP $authldap )
$authldap AuthLDAP AuthLDAP object

testLDAPConnection() static public method

Test a LDAP connection
static public testLDAPConnection ( $auths_id, $replicate_id ) : boolean
$auths_id ID of the LDAP server
$replicate_id use a replicate if > 0 (default -1)
return boolean connection succeeded ?

tryLdapAuth() static public method

Try to authentify a user by checking all the directories
static public tryLdapAuth ( $auth, $login, $password, $auths_id, $user_dn = false, $break = true ) : identification
$auth identification object
$login user login
$password user password
$auths_id auths_id already used for the user (default 0)
$user_dn user LDAP DN if present (false by default)
$break if user is not found in the first directory, stop searching or try the following ones (true by default)
return identification object

tryToConnectToServer() static public method

Try to connect to a ldap server
static public tryToConnectToServer ( $ldap_method, $login, $password ) : link
$ldap_method ldap_method array to use
$login User Login
$password User Password
return link to the LDAP server : false if connection failed

unsetUndisclosedFields() public static method

public static unsetUndisclosedFields ( &$fields )

useAuthLdap() static public method

Is the LDAP authentication used ?
static public useAuthLdap ( ) : boolean
return boolean

Property Details

$dohistory public_oe property

From CommonDBTM
public $dohistory

$rightname static_oe public_oe property

static public $rightname