Select Git revision
ldap.class.php
-
Hahn Axel (hahn) authored
extend ldap class for search, DnExist check projects: load + save config in ldap and json (can be set in config)
Hahn Axel (hahn) authoredextend ldap class for search, DnExist check projects: load + save config in ldap and json (can be set in config)
ldap.class.php 17.68 KiB
<?php
/**
* IML LDAP CONNECTOR FOR USER AUTHENTICATION
*
* @author axel.hahn@iml.unibe.ch
*/
class imlldap {
private $_aLdap = array(
'server' => false,
'port' => false,
'DnLdapUser' => false, // ldap rdn oder dn
'PwLdapUser' => false,
'DnUserNode' => false, // ou=People...
'DnAppNode' => false, // cn=AppGroup...
'protoVersion' => 3,
'debugLevel' => 0,
);
private $_ldapConn = false;
private $_ldapBind = false;
var $bDebug = false;
/**
* constructor
* @param array $aConfig optional set ldap connection
*/
public function __construct($aConfig = array()) {
if (!function_exists("ldap_connect")){
die(__CLASS__ . " ERROR: php-ldap module is not installed on this server.");
}
if (count($aConfig)) {
$this->setConfig($aConfig);
}
}
public function __destruct() {
$this->close();
}
// ----------------------------------------------------------------------
// write debug text
// ----------------------------------------------------------------------
/**
* turn debug messages on;
* if this detail level is not enough, set a value with key debugLevel in
* ldap config array
* @see setConfig()
*/
public function debugOn(){
$this->bDebug=true;
if($this->_aLdap['debugLevel']){
$this->_w(__FUNCTION__ . ' setting debug level ' . $this->_aLdap['debugLevel']);
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, $this->_aLdap['debugLevel']);
}
}
/**
* turn debug messages off
*/
public function debugOff(){
$this->bDebug=false;
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 0);
}
private function _w($sText) {
if (!$this->bDebug) {