Select Git revision
ldap.class.php
ldap.class.php 26.29 KiB
<?php
/**
* IML LDAP CLASS
*
* - ldap auth
* - CRUD actions on ldap leafs
*
* @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);
}
/**