CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

7192.diff

Patch file for the extension. - Tizian Schmidlin, 2010-08-12 12:52

Download (8.3 kB)

 
eu_ldap_patch/ext_conf_template.txt 2010-08-12 12:40:45.000000000 +0200
10 10
# cat=basic/enable; type=int+; label=Logging level (0 = none, 1 = normal, 2 = extensive).
11 11
logLevel = 1
12 12

  
13
# cat=basic/enable; type=boolean; label=General: Enable NTLM SSO. If checked a windows user of a domain may automatically login throug his NT User.
14
enableSSO = 1
15

  
16
# cat=basic/enable; type=input; label=Enable NTLM SSO: one or more PID where the ldap server records and users for SSO are stored z.B. "1,2"
17
ssoPID = 2
18

  
eu_ldap_patch/ext_emconf.php 2010-08-11 10:44:30.000000000 +0200
12 12

  
13 13
$EM_CONF[$_EXTKEY] = array(
14 14
	'title' => 'LDAP',
15
	'description' => 'LDAP Integration',
15
	'description' => 'LDAP Integration - modified',
16 16
	'category' => 'module',
17 17
	'shy' => 0,
18
	'version' => '2.8.8',
18
	'version' => '12.8.8',
19 19
	'dependencies' => '',
20 20
	'conflicts' => '',
21 21
	'priority' => '',
eu_ldap_patch/mod1/class.tx_euldap_div.php 2010-08-11 14:10:14.000000000 +0200
848 848
 * @param	array		$server_info: all ldap-server configuration needed (see table eu_ldapserver)
849 849
 * @param	string		$username: username to be checked in ldap
850 850
 * @param	string		$password: password to be checked
851
 * @param	boolean		$enableSSO: if 1 no password is expected and SSO value is trusted blindly
851 852
 * @return	array		ldap-user attributes, if found and authentificated
852 853
 */
853
	function checkNTUser ($server_info, $username, $password) {
854
	function checkNTUser ($server_info, $username, $password, $enableSSO = false) {
854 855
	
855 856
		// convert character set local -> remote
856 857
		$username = $this->csObj->conv($username, $this->localChar, $this->remoteChar);
......
894 895
				}
895 896
			}
896 897
			
898
			// authenticate user over ldap with password, continue if SSO/NTLM is activated and we trust apache/mod_ntlm
897 899
			if ($username && $password) {
898 900
				@ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
899 901
				if ($this->conf['logLevel'] == 2) t3lib_div::devLog('try to bind: '.$username.' / '.$password, 'eu_ldap', 0);
900
				$r = @ldap_bind($ds,$username,$password);
902
				
903
				// authenticate with cuser and cpass if $enableSSO because with SSO password is not existing
904
				if($enableSSO) {
905
					$r = @ldap_bind($ds, $cuser, $cpass);
906
				} else {
907
					$r = @ldap_bind($ds,$username,$password);
908
				}
909
				
901 910
				if ($r) {
902 911
					if ($this->conf['logLevel'] == 2) t3lib_div::devLog('bind successful', 'eu_ldap', -1);
903 912
					
eu_ldap_patch/sv1/class.tx_euldap_sv1.php 2010-08-11 14:09:12.000000000 +0200
46 46
			t3lib_div::devLog('No ldap extension in PHP', 'eu_ldap', 3);
47 47
			return false;
48 48
		}
49
		
50
		// get configuration form extension manager
49 51
		$this->conf = unserialize($TYPO3_CONF_VARS['EXT']['extConf']['eu_ldap']);
50 52
		
51 53
		return parent::init();
......
57 59
		$this->password = $this->loginData['uident_text'];
58 60
		$this->username = $this->loginData['uname'];
59 61
		
62
		// use SSO information if SSO is available and enabled
63
		if($this->conf['enableSSO'] && !empty($_SERVER['PHP_AUTH_USER']) && empty($this->username) && empty($this->password)) {
64
			$this->username = $_SERVER['PHP_AUTH_USER'];
65
			$this->loginData['status'] = 'login';
66
			$this->password = 'sso-no-password'.time();
67
			$this->authInfo['db_user']['checkPidList'] = $this->conf['ssoPID'];
68
			$this->authInfo['db_user']['check_pid_clause'] = 'AND pid IN ('.$this->conf['ssoPID'].') ';
69
		}
70
		
60 71
	}
61 72
	
62 73
	function getUser()	{
63 74
		$OK = false;
64 75
		$user = null;
76
		
65 77
		// $user['authenticated'] = false;
66 78
		if ($this->conf['logLevel'] > 0) t3lib_div::devLog('getUser() called', 'eu_ldap', 0);
67 79
		if ($this->loginData['status'] == 'login') {
......
102 114
						'',
103 115
						'sorting'
104 116
					);
117
					die($sql);
105 118
					t3lib_div::devLog('looking for LDAP server records: '.$sql, 'eu_ldap', 0);
106 119
				}
107 120
				
108 121
				$objLdap = new tx_euldap_div;
109 122
				
110 123
				while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbres)) && !($OK)) {
124
					
111 125
					if ($this->conf['logLevel'] == 1) t3lib_div::devLog('checking server: '.$row['server'], 'eu_ldap', 0);
112
					$ldapres = $objLdap->checkNTUser($row, $this->username, $this->password);
126
					// get ldap user information - pass on the SSO setting, checkNTUser works different if SSO is enabled
127
					$ldapres = $objLdap->checkNTUser($row, $this->username, $this->password, $this->conf['enableSSO']);
113 128
					if (is_array($ldapres)) {
114 129
						if ($this->conf['logLevel'] >= 1) t3lib_div::devLog('Login successful', 'eu_ldap', -1);
115 130
						if ($row['automatic_import']) {
......
136 151
				}
137 152
			}
138 153
		}
154
		
139 155
		return $user;
140 156
	}
141 157
	
......
145 161
	 * @param	array		Data of user.
146 162
	 * @return	boolean
147 163
	 */
148
function authUser(&$user)	{
149
	global $TYPO3_CONF_VARS;
150
	
151
	$OK = 100;
152
	
153
	// $this->pObj->challengeStoredInCookie = false;
154
	if ($this->username)	{
155
		$OK = 0;
156

  
157
		$OK = $user['authenticated'];
158

  
159
		if(!$OK)     {
160
				// Failed login attempt (wrong password) - write that to the log!
164
	function authUser(&$user)	{
165
		global $TYPO3_CONF_VARS;
166
		
167
		$OK = 100;
168
		
169
		// $this->pObj->challengeStoredInCookie = false;
170
		if ($this->username)	{
171
			$OK = 0;
172
	
173
			$OK = $user['authenticated'];
174
	
175
			if(!$OK)     {
176
					// Failed login attempt (wrong password) - write that to the log!
177
				if ($this->writeAttemptLog) {
178
					$this->writelog(255,3,3,1,
179
						"Login-attempt from %s (%s), username '%s', password not accepted!",
180
						array($this->info['REMOTE_ADDR'], $this->info['REMOTE_HOST'], $this->username));
181
				}
182
				if ($this->conf['logLevel'] == 1) t3lib_div::devLog('Password not accepted: '.$this->password, 'eu_ldap', 2);
183
			}
184
			
185
			$OK = $OK ? 200 : ($this->conf['onlyLDAP'] ? 0 : 100);
186
		}
187
		
188
		if ($OK && $user['lockToDomain'] && $user['lockToDomain']!=$this->authInfo['HTTP_HOST'])	{
189
			// Lock domain didn't match, so error:
161 190
			if ($this->writeAttemptLog) {
162 191
				$this->writelog(255,3,3,1,
163
					"Login-attempt from %s (%s), username '%s', password not accepted!",
164
					array($this->info['REMOTE_ADDR'], $this->info['REMOTE_HOST'], $this->username));
192
					"Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!",
193
					Array($this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->authInfo['db_user']['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']));
194
				t3lib_div::sysLog(
195
					sprintf( "Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!", $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->authInfo['db_user']['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST'] ),
196
					'Core',
197
					0
198
				);
165 199
			}
166
			if ($this->conf['logLevel'] == 1) t3lib_div::devLog('Password not accepted: '.$this->password, 'eu_ldap', 2);
200
			$OK = false;
167 201
		}
168 202
		
169
		$OK = $OK ? 200 : ($this->conf['onlyLDAP'] ? 0 : 100);
203
		return $OK;
170 204
	}
171
	
172
	if ($OK && $user['lockToDomain'] && $user['lockToDomain']!=$this->authInfo['HTTP_HOST'])	{
173
		// Lock domain didn't match, so error:
174
		if ($this->writeAttemptLog) {
175
			$this->writelog(255,3,3,1,
176
				"Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!",
177
				Array($this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->authInfo['db_user']['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']));
178
			t3lib_div::sysLog(
179
				sprintf( "Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!", $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->authInfo['db_user']['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST'] ),
180
				'Core',
181
				0
182
			);
183
		}
184
		$OK = false;
185
	}
186
	
187
	return $OK;
188
}
189 205

  
190 206
}
191 207