Skip to content

Commit 7d781d3

Browse files
author
robin.kluth
committed
Disable Autodetection if getUserIP is not available
1 parent f3ea2ff commit 7d781d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/LdapAuth.php

+8
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ private function serviceping($host, $port = 389, $timeout = 5)
131131
public function autoDetect($overrideIp = false)
132132
{
133133

134+
if (!isset(Yii::$app->request) || !method_exists(Yii::$app->request, 'getUserIP')) {
135+
Yii::debug("[Autodetect] Skipping autodetection: No getUserIP method found!", __METHOD__);
136+
return 0;
137+
}
138+
134139
Yii::debug('[Autodetect] Started IP autodetection!', __METHOD__);
135140

136141
if (count($this->domains) <= 1) {
@@ -191,6 +196,9 @@ public function login($username, $password, $domainKey = false, $fetchUserDN = f
191196

192197
$firstArrayKey = !$userDNSearch ? false : array_key_first($userDNSearch);
193198

199+
Yii::debug("userDNSearch result:", __METHOD__);
200+
Yii::debug($userDNSearch, __METHOD__);
201+
194202
if ($userDNSearch && count($userDNSearch) == 1 && $firstArrayKey) {
195203
Yii::debug("Overwrite username " . $username . " to " . $userDNSearch[$firstArrayKey]['dn'], __METHOD__);
196204
$this->_curDn = $username = $userDNSearch[$firstArrayKey]['dn'];

0 commit comments

Comments
 (0)