Subversion Repositories ALCASAR

Rev

Rev 776 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 776 Rev 779
Line 12... Line 12...
12
	
12
	
13
	public function __construct($instanceName=null) {
13
	public function __construct($instanceName=null) {
14
		if ($instanceName!== null)
14
		if ($instanceName!== null)
15
			$this->instanceName = $instanceName;
15
			$this->instanceName = $instanceName;
16
		// LDAP setting
16
		// LDAP setting
17
		$this->_items['protocol']					= 'ldap://';
17
		$this->_items['protocol']					= 'ldap';
18
		$this->_items['host']						= 'test';
18
		$this->_items['host']						= 'test';
19
		$this->_items['server']						= $this->_items['protocol'].$this->_items['host'];
19
		$this->_items['server']						= $this->_items['protocol'].'://'.$this->_items['host'];
20
		$this->_items['port']						= '389';//not use yet (689 = ldaps)
20
		$this->_items['port']						= '389';//not use yet (689 = ldaps)
21
		$this->_items['identity']					= '';
21
		$this->_items['identity']					= '';
22
		$this->_items['password']					= '';
22
		$this->_items['password']					= '';
23
		$this->_items['basedn']						= 'dc=example,dc=com';
23
		$this->_items['basedn']						= 'dc=example,dc=com';
-
 
24
		$this->_items['uid']						= 'uid';
24
		$this->_items['filter']						= '(uid=%{Stripped-User-Name:-%{User-Name}})';
25
		$this->_items['filter']						= "($this->_items['uid']=%{Stripped-User-Name:-%{User-Name}})";
25
		$this->_items['base_filter']				= '';
26
		$this->_items['base_filter']				= '';
26
		$this->_items['ldap_connections_number']	= '5';
27
		$this->_items['ldap_connections_number']	= '5';
27
		$this->_items['timeout']					= '4';
28
		$this->_items['timeout']					= '4';
28
		$this->_items['timelimit']					= '3';
29
		$this->_items['timelimit']					= '3';
29
		$this->_items['net_timeout'] 				= '1';
30
		$this->_items['net_timeout'] 				= '1';
Line 68... Line 69...
68
		}
69
		}
69
		// nothing else!
70
		// nothing else!
70
	}
71
	}
71
	public function __set($attr, $value){// to set an $item
72
	public function __set($attr, $value){// to set an $item
72
		if (array_key_exists($attr, $this->_items)){
73
		if (array_key_exists($attr, $this->_items)){
-
 
74
			switch ($attr){
-
 
75
				case "protocol":
-
 
76
					$this->_items['protocol']	= $value;
-
 
77
					$this->_items['server']		= $this->_items['protocol'].'://'.$this->_items['host'];
-
 
78
					break;
-
 
79
				case "host":
-
 
80
					$this->_items['host']		= $value;
-
 
81
					$this->_items['server']		= $this->_items['protocol'].'://'.$this->_items['host'];
-
 
82
					break;
-
 
83
				case "server":
-
 
84
					// extract protocole & host
-
 
85
					$tmp = explode("://",$value,2);
-
 
86
					if (count($tmp) == 2){
-
 
87
						$this->_items['protocol'] = $tmp[0];
-
 
88
						$this->_items['host'] 	= $tmp[1];
-
 
89
					} else {
-
 
90
						$this->_items['protocol'] = 'ldap';
-
 
91
						$this->_items['host'] 	= $tmp[1];
-
 
92
					}
-
 
93
					$this->_items['server'] = $this->_items['protocol'].'://'.$this->_items['host'];
-
 
94
					break;
-
 
95
				case "uid":
-
 
96
					$this->_items['uid']		= $value;
-
 
97
					$this->_items['filter']		= "($this->_items['uid']=%{Stripped-User-Name:-%{User-Name}})";
-
 
98
					break;
-
 
99
				case "filter":
-
 
100
					// extract uid
-
 
101
					if (preg_match('`^[\(]([\sa-zA-Z0-9_-]*)=\%\{Stripped\-User\-Name:\-\%\{User-Name\}\}\)`',$value)){
-
 
102
						$this->_items['uid'] = preg_replace('`^[\(]([\sa-zA-Z0-9_-]*)=\%\{Stripped\-User\-Name:\-\%\{User-Name\}\}\)`','$1',$value);
-
 
103
					} else {
-
 
104
						$this->_items['uid'] = 'uid';
-
 
105
					}
-
 
106
					$this->_items['filter']		= "($this->_items['uid']=%{Stripped-User-Name:-%{User-Name}})";
-
 
107
					break;
-
 
108
				default:
73
			$this->_items[$attr] = $value;
109
					$this->_items[$attr] = $value;
-
 
110
			}
74
		} elseif (array_key_exists($attr, $this->_tls)){
111
		} elseif (array_key_exists($attr, $this->_tls)){
75
			$this->_tls[$attr] = $value;
112
			$this->_tls[$attr] = $value;
76
		}
113
		}
77
	}
114
	}
78
	public function load($confFile){
115
	public function load($confFile){