'attributes' => array('dn'), // List of attributes to read from the server
'vlv' => false, // Enable Virtual List View to more efficiently fetch paginated data (if server supports it)
'config_root_dn' => 'cn=config', // Root DN to read config (e.g. vlv indexes) from
'numsub_filter' => '(objectClass=organizationalUnit)', // with VLV, we also use numSubOrdinates to query the total number of records. Set this filter to get all numSubOrdinates attributes for counting
'sizelimit' => '0', // Enables you to limit the count of entries fetched. Setting this to 0 means no limit.
'timelimit' => '0', // Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit.
'network_timeout' => 10, // The timeout (in seconds) for connect + bind arrempts. This is only supported in PHP >= 5.3.0 with OpenLDAP 2.x
'referrals' => true|false, // Sets the LDAP_OPT_REFERRALS option. Mostly used in multi-domain Active Directory setups
);
*/
/**
* Model class to access an LDAP directories
*
* @package Framework
* @subpackage LDAP
*/
classrcube_ldap_generic
{
constUPDATE_MOD_ADD=1;
constUPDATE_MOD_DELETE=2;
constUPDATE_MOD_REPLACE=4;
constUPDATE_MOD_FULL=7;
public$conn;
public$vlv_active=false;
/** private properties */
protected$cache=null;
protected$config=array();
protected$attributes=array('dn');
protected$entries=null;
protected$result=null;
protected$debug=false;
protected$list_page=1;
protected$page_size=10;
protected$vlv_config=null;
/**
* Object constructor
*
* @param array $p LDAP connection properties
*/
function__construct($p)
{
$this->config=$p;
if(is_array($p['attributes']))
$this->attributes=$p['attributes'];
if(!is_array($p['hosts'])&&!empty($p['host']))
$this->config['hosts']=array($p['host']);
}
/**
* Activate/deactivate debug mode
*
* @param boolean $dbg True if LDAP commands should be logged
*/
publicfunctionset_debug($dbg=true)
{
$this->debug=$dbg;
}
/**
* Set connection options
*
* @param mixed $opt Option name as string or hash array with multiple options
* @param mixed $val Option value
*/
publicfunctionset_config($opt,$val=null)
{
if(is_array($opt))
$this->config=array_merge($this->config,$opt);
else
$this->config[$opt]=$value;
}
/**
* Enable caching by passing an instance of rcube_cache to be used by this object
*
* @param object rcube_cache Instance or False to disable caching
*/
publicfunctionset_cache($cache_engine)
{
$this->cache=$cache_engine;
}
/**
* Set properties for VLV-based paging
*
* @param number $page Page number to list (starting at 1)
* @param number $size Number of entries to display on one page