| 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 |
|