Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php |
— | — | @@ -857,6 +857,14 @@ |
858 | 858 | |
859 | 859 | if ( $username != '' ) { |
860 | 860 | $this->printDebug("Username isn't empty.",1); |
| 861 | + |
| 862 | + //We want to use the username returned by LDAP |
| 863 | + //if it exists |
| 864 | + if ( $this->LDAPUsername != '' ) { |
| 865 | + $this->printDebug("Using LDAPUsername.",1); |
| 866 | + $username = $this->LDAPUsername; |
| 867 | + } |
| 868 | + |
861 | 869 | //Change username to lowercase so that multiple user accounts |
862 | 870 | //won't be created for the same user. |
863 | 871 | $username = strtolower($username); |
— | — | @@ -1433,6 +1441,7 @@ |
1434 | 1442 | global $wgAuth; |
1435 | 1443 | global $wgLDAPAutoAuthMethod; |
1436 | 1444 | global $wgLDAPUseSmartcardAuth; |
| 1445 | + global $wgLDAPSmartcardDomain; |
1437 | 1446 | |
1438 | 1447 | $wgAuth = new LdapAuthenticationPlugin(); |
1439 | 1448 | |
— | — | @@ -1450,6 +1459,7 @@ |
1451 | 1460 | $wgHooks['AutoAuthenticate'][] = 'SSLAuth'; /* Hook for magical authN */ |
1452 | 1461 | $wgHooks['PersonalUrls'][] = 'NoLogout'; /* Disallow logout link */ |
1453 | 1462 | $wgLDAPUseSmartcardAuth = true; |
| 1463 | + $wgAuth->setDomain($wgLDAPSmartcardDomain); |
1454 | 1464 | } |
1455 | 1465 | break; |
1456 | 1466 | default: |
— | — | @@ -1471,18 +1481,9 @@ |
1472 | 1482 | global $wgLDAPSSLUsername; |
1473 | 1483 | global $wgUser; |
1474 | 1484 | global $wgAuth; |
1475 | | - global $wgLDAPSmartcardDomain; |
1476 | | - global $wgLDAPUseSmartcardAuth; |
1477 | 1485 | |
1478 | 1486 | $wgAuth->printDebug("Entering SSLAuth.",1); |
1479 | 1487 | |
1480 | | - if (!$wgLDAPUseSmartcardAuth) { |
1481 | | - $wgAuth->printDebug("Not using smartcard authentication, returning.",1); |
1482 | | - return; |
1483 | | - } |
1484 | | - |
1485 | | - $wgAuth->setDomain($wgLDAPSmartcardDomain); |
1486 | | - |
1487 | 1488 | //Give us a user, see if we're around |
1488 | 1489 | $tmpuser = User::LoadFromSession(); |
1489 | 1490 | |
— | — | @@ -1490,21 +1491,22 @@ |
1491 | 1492 | if($tmpuser->isLoggedIn()) { |
1492 | 1493 | $wgAuth->printDebug("User is already logged in.",1); |
1493 | 1494 | return; |
1494 | | - } else { |
1495 | | - $wgAuth->printDebug("User is not logged in, we need to authenticate",1); |
1496 | | - $authenticated = $wgAuth->authenticate($wgLDAPSSLUsername); |
1497 | | - if (!$authenticated) { |
1498 | | - //If the user doesn't exist in LDAP, there isn't much reason to |
1499 | | - //go any further. |
1500 | | - $wgAuth->printDebug("User wasn't found in LDAP, exiting.",1); |
1501 | | - return; |
1502 | | - } |
| 1495 | + } |
1503 | 1496 | |
1504 | | - //We need the username that MediaWiki will always use, *not* the one we |
1505 | | - //get from LDAP. |
1506 | | - $mungedUsername = $wgAuth->getCanonicalName($wgAuth->getLDAPUsername()); |
| 1497 | + //The user hasn't already been authenticated, let's check them |
| 1498 | + $wgAuth->printDebug("User is not logged in, we need to authenticate",1); |
| 1499 | + $authenticated = $wgAuth->authenticate($wgLDAPSSLUsername); |
| 1500 | + if (!$authenticated) { |
| 1501 | + //If the user doesn't exist in LDAP, there isn't much reason to |
| 1502 | + //go any further. |
| 1503 | + $wgAuth->printDebug("User wasn't found in LDAP, exiting.",1); |
| 1504 | + return; |
1507 | 1505 | } |
1508 | 1506 | |
| 1507 | + //We need the username that MediaWiki will always use, *not* the one we |
| 1508 | + //get from LDAP. |
| 1509 | + $mungedUsername = $wgAuth->getCanonicalName($wgLDAPSSLUsername); |
| 1510 | + |
1509 | 1511 | $wgAuth->printDebug("User exists in LDAP; finding the user by name in MediaWiki.",1); |
1510 | 1512 | |
1511 | 1513 | //Is the user already in the database? |
— | — | @@ -1554,9 +1556,6 @@ |
1555 | 1557 | //Create the user |
1556 | 1558 | $lf->initUser($wgUser); |
1557 | 1559 | |
1558 | | - //Update the user's settings |
1559 | | - $wgAuth->updateUser($wgUser); |
1560 | | - |
1561 | 1560 | //Initialize the user |
1562 | 1561 | $wgUser->setupSession(); |
1563 | 1562 | $wgUser->setCookies(); |