@@ -94,7 +94,7 @@ public function autoDetect($overrideIp = false)
94
94
$ index ++;
95
95
}
96
96
97
- Yii::debug ('[Autodetect] No suitable domain found :( ' , __METHOD__ );
97
+ Yii::warning ('[Autodetect] No suitable domain found :( ' , __METHOD__ );
98
98
return false ;
99
99
}
100
100
@@ -110,6 +110,31 @@ public function login($username, $password, $domainKey)
110
110
$ ssl = isset ($ domainData ['useSSL ' ]) && $ domainData ['useSSL ' ];
111
111
Yii::debug ('Use SSL here? ' . ($ ssl ? 'Yes ' : 'No ' ));
112
112
113
+ if ($ ssl ) {
114
+ // When using SSL, we have to set some env variables and create an ldap controlfile - otherwirse a connect with non valid certificat will fail!
115
+
116
+ /**
117
+ * Inhalt der .ldaprc:
118
+ * TLS_REQCERT allow
119
+ *
120
+ */
121
+ $ ldaprcfile = $ _SERVER ['HOME ' ] . '/.ldaprc ' ;
122
+
123
+ if (!file_exists ($ ldaprcfile )) {
124
+ // Try to create the file
125
+ if (!file_put_contents ($ ldaprcfile , 'TLS_REQCERT allow ' )) {
126
+ Yii::error ('Cannot create required .ldaprc control file! ' );
127
+ return false ;
128
+ }
129
+ } else {
130
+ Yii::debug ('.ldaprc file exists! ' );
131
+ }
132
+
133
+ putenv ('LDAPCONF= ' . $ ldaprcfile );
134
+ putenv ('LDAPTLS_REQCERT=allow ' );
135
+ putenv ('TLS_REQCERT=allow ' );
136
+ }
137
+
113
138
Yii::debug ('Trying to connect to Domain # ' . $ domainKey . ' ( ' . $ domainData ['hostname ' ] . ') ' );
114
139
115
140
if (!self ::serviceping ($ domainData ['hostname ' ], $ ssl ? 636 : null )) {
@@ -124,7 +149,7 @@ public function login($username, $password, $domainKey)
124
149
125
150
$ l = @ldap_connect ($ hostPrefix , $ port );
126
151
if (!$ l ) {
127
- Yii::debug ('Connect failed! ' . ldap_error ($ l ), 'ldapAuth ' );
152
+ Yii::warning ('Connect failed! ' . ldap_error ($ l ), 'ldapAuth ' );
128
153
return false ;
129
154
}
130
155
@@ -139,7 +164,7 @@ public function login($username, $password, $domainKey)
139
164
$ b = @ldap_bind ($ l , $ bind_dn , $ password );
140
165
141
166
if (!$ b ) {
142
- Yii::debug ('Bind failed! ' . ldap_error ($ l ), 'ldapAuth ' );
167
+ Yii::warning ('Bind failed! ' . ldap_error ($ l ), 'ldapAuth ' );
143
168
return false ;
144
169
}
145
170
0 commit comments