summaryrefslogtreecommitdiff
path: root/lib/Kolab/FreeBusy/DirectoryLDAP.php
blob: ae80bfc2d33b4dd1f089334916070a20a82813bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php

namespace Kolab\FreeBusy;

// PEAR modules operate in global namespace
use \Net_LDAP3;

/**
 *
 */
class DirectoryLDAP extends Directory
{
	private $ldap;
	private $logger;

	/**
	 * Default constructor loading directory configuration
	 */
	public function __construct($config)
	{
		$ldap_config = array(
			
		);

		$this->logger = Logger::get('ldap');
		$this->ldap = new Net_LDAP3($ldap_config);
		$this->ldap->config_set('log_hook', array($this, 'log'));
		$this->ldap->connect();
	}

	/**
	 * Callback for Net_LDAP3 logging
	 */
	public function log($log)
	{
		// TODO: map $log[0] levels
		$msg = is_array($log[1]) ? join('; ', $log[1]) : strval($log[1]);
		$this->logger->addRecord($log[0], $msg);
	}

	/**
	 * @see Directory::resolve()
	 */
	public function resolve($user)
	{
		$result = array('u' => $user);

		return false;
	}

}