Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php |
— | — | @@ -204,12 +204,16 @@ |
205 | 205 | * |
206 | 206 | * @access private |
207 | 207 | */ |
208 | | - function connect() { |
| 208 | + function connect( $domain='' ) { |
209 | 209 | global $wgLDAPServerNames; |
210 | 210 | global $wgLDAPPort; |
211 | 211 | global $wgLDAPEncryptionType; |
212 | 212 | global $wgLDAPOptions; |
213 | 213 | |
| 214 | + if ( $domain == '' ) { |
| 215 | + $domain = $_SESSION['wsDomain']; |
| 216 | + } |
| 217 | + |
214 | 218 | $this->printDebug( "Entering Connect", NONSENSITIVE ); |
215 | 219 | |
216 | 220 | if ( !function_exists( 'ldap_connect' ) ) { |
— | — | @@ -218,8 +222,8 @@ |
219 | 223 | } |
220 | 224 | |
221 | 225 | // If the admin didn't set an encryption type, we default to tls |
222 | | - if ( isset( $wgLDAPEncryptionType[$_SESSION['wsDomain']] ) ) { |
223 | | - $encryptionType = $wgLDAPEncryptionType[$_SESSION['wsDomain']]; |
| 226 | + if ( isset( $wgLDAPEncryptionType[$domain] ) ) { |
| 227 | + $encryptionType = $wgLDAPEncryptionType[$domain]; |
224 | 228 | } else { |
225 | 229 | $encryptionType = "tls"; |
226 | 230 | } |
— | — | @@ -244,12 +248,12 @@ |
245 | 249 | // Make a space separated list of server strings with the ldap:// or ldaps:// |
246 | 250 | // string added. |
247 | 251 | $servers = ""; |
248 | | - $tmpservers = $wgLDAPServerNames[$_SESSION['wsDomain']]; |
| 252 | + $tmpservers = $wgLDAPServerNames[$domain]; |
249 | 253 | $tok = strtok( $tmpservers, " " ); |
250 | 254 | while ( $tok ) { |
251 | | - if ( isset( $wgLDAPPort[$_SESSION['wsDomain']] ) ) { |
252 | | - $this->printDebug( "Using non-standard port: " . $wgLDAPPort[$_SESSION['wsDomain']], SENSITIVE ); |
253 | | - $servers = $servers . " " . $serverpre . $tok . ":" . $wgLDAPPort[$_SESSION['wsDomain']]; |
| 255 | + if ( isset( $wgLDAPPort[$domain] ) ) { |
| 256 | + $this->printDebug( "Using non-standard port: " . $wgLDAPPort[$domain], SENSITIVE ); |
| 257 | + $servers = $servers . " " . $serverpre . $tok . ":" . $wgLDAPPort[$domain]; |
254 | 258 | } else { |
255 | 259 | $servers = $servers . " " . $serverpre . $tok; |
256 | 260 | } |
— | — | @@ -264,8 +268,8 @@ |
265 | 269 | ldap_set_option( $this->ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3 ); |
266 | 270 | ldap_set_option( $this->ldapconn, LDAP_OPT_REFERRALS, 0 ); |
267 | 271 | |
268 | | - if ( isset( $wgLDAPOptions[$_SESSION['wsDomain']] ) ) { |
269 | | - $options = $wgLDAPOptions[$_SESSION['wsDomain']]; |
| 272 | + if ( isset( $wgLDAPOptions[$domain] ) ) { |
| 273 | + $options = $wgLDAPOptions[$domain]; |
270 | 274 | foreach ( $options as $key => $value ) { |
271 | 275 | if ( !ldap_set_option( $this->ldapconn, constant( $key ), $value ) ) { |
272 | 276 | $this->printDebug( "Can't set option to LDAP! Option code and value: " . $key . "=" . $value, 1 ); |
— | — | @@ -1376,8 +1380,11 @@ |
1377 | 1381 | } |
1378 | 1382 | } |
1379 | 1383 | } |
| 1384 | + $this->printDebug( "Got the following groups:", SENSITIVE, $groups["dn"] ); |
1380 | 1385 | |
1381 | 1386 | $this->userLDAPGroups = $groups; |
| 1387 | + } else { |
| 1388 | + $this->printDebug( "memberOf attribute isn't set:", NONSENSITIVE ); |
1382 | 1389 | } |
1383 | 1390 | } else { |
1384 | 1391 | $this->printDebug( "Searching for the groups", NONSENSITIVE ); |