Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php |
— | — | @@ -214,7 +214,7 @@ |
215 | 215 | * @access public |
216 | 216 | */ |
217 | 217 | function authenticate( $username, $password='' ) { |
218 | | - global $wgLDAPRetrievePrefs; |
| 218 | + global $wgLDAPRetrievePrefs, $wgLDAPPreferences; |
219 | 219 | global $wgLDAPGroupDN, $wgLDAPRequiredGroups; |
220 | 220 | global $wgLDAPGroupUseFullDN, $wgLDAPGroupUseRetrievedUsername; |
221 | 221 | global $wgLDAPUseLDAPGroups; |
— | — | @@ -394,8 +394,43 @@ |
395 | 395 | } |
396 | 396 | |
397 | 397 | //Retrieve preferences |
398 | | - if ( isset( $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) && $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) { |
| 398 | + if ( isset( $wgLDAPPreferences[$_SESSION['wsDomain']] ) ) { |
399 | 399 | $this->printDebug( "Retrieving preferences", NONSENSITIVE ); |
| 400 | + $entry = @ldap_read( $ldapconn, $userdn, "objectclass=*" ); |
| 401 | + $info = @ldap_get_entries( $ldapconn, $entry ); |
| 402 | + $prefs = $wgLDAPPreferences[$_SESSION['wsDomain']]; |
| 403 | + foreach ( array_keys( $prefs ) as $key ) { |
| 404 | + switch ( $key ) { |
| 405 | + case "email": |
| 406 | + if ( isset( $info[0]["$prefs[$key]"] ) ) { |
| 407 | + $this->email = $info[0]["$prefs[$key]"][0]; |
| 408 | + $this->printDebug( "Retrieved email ($this->email) using attribute ($prefs[$key])", NONSENSITIVE ); |
| 409 | + } |
| 410 | + break; |
| 411 | + case "language": |
| 412 | + if ( isset( $info[0]["$prefs[$key]"] ) ) { |
| 413 | + $this->lang = $info[0][$prefs[$key]][0]; |
| 414 | + $this->printDebug( "Retrieved language ($this->lang) using attribute ($prefs[$key])", NONSENSITIVE ); |
| 415 | + } |
| 416 | + break; |
| 417 | + case "nickname": |
| 418 | + if ( isset( $info[0]["$prefs[$key]"] ) ) { |
| 419 | + $this->nickname = $info[0]["$prefs[$key]"][0]; |
| 420 | + $this->printDebug( "Retrieved nickname ($this->nickname) using attribute ($prefs[$key])", NONSENSITIVE ); |
| 421 | + } |
| 422 | + break; |
| 423 | + case "realname": |
| 424 | + if ( isset( $info[0]["$prefs[$key]"] ) ) { |
| 425 | + $this->realname = $info[0]["$prefs[$key]"][0]; |
| 426 | + $this->printDebug( "Retrieved realname ($this->realname) using attribute ($prefs[$key])", NONSENSITIVE ); |
| 427 | + } |
| 428 | + break; |
| 429 | + } |
| 430 | + } |
| 431 | + } else if ( isset( $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) && $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) { |
| 432 | + //DEPRECATED. Kept for backwards compatibility. |
| 433 | + $this->printDebug( "Retrieving preferences", NONSENSITIVE ); |
| 434 | + $this->printDebug( '$wgLDAPRetrievePrefs is a DEPRECATED option, please use $wgLDAPPreferences.', NONSENSITIVE ); |
400 | 435 | |
401 | 436 | $entry = @ldap_read( $ldapconn, $userdn, "objectclass=*" ); |
402 | 437 | $info = @ldap_get_entries( $ldapconn, $entry ); |
— | — | @@ -723,6 +758,8 @@ |
724 | 759 | global $wgLDAPUpdateLDAP, $wgLDAPMailPassword; |
725 | 760 | global $wgLDAPUseLocal; |
726 | 761 | |
| 762 | + $this->printDebug( "Entering allowPasswordChange", NONSENSITIVE ); |
| 763 | + |
727 | 764 | $retval = false; |
728 | 765 | |
729 | 766 | // Local domains need to be able to change passwords |
— | — | @@ -886,7 +923,7 @@ |
887 | 924 | * TODO: fix the setExternalID stuff |
888 | 925 | */ |
889 | 926 | function updateUser( &$user ) { |
890 | | - global $wgLDAPRetrievePrefs; |
| 927 | + global $wgLDAPRetrievePrefs, $wgLDAPPreferences; |
891 | 928 | global $wgLDAPUseLDAPGroups; |
892 | 929 | global $wgLDAPUniqueBlockLogin, $wgLDAPUniqueRenameUser; |
893 | 930 | |
— | — | @@ -901,19 +938,24 @@ |
902 | 939 | |
903 | 940 | //If we aren't pulling preferences, we don't want to accidentally |
904 | 941 | //overwrite anything. |
905 | | - if ( isset( $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) && $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) { |
| 942 | + if ( ( isset( $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) && $wgLDAPRetrievePrefs[$_SESSION['wsDomain']] ) |
| 943 | + || isset( $wgLDAPPreferences[$_SESSION['wsDomain']] ) ) { |
906 | 944 | $this->printDebug( "Setting user preferences.", NONSENSITIVE ); |
907 | 945 | |
908 | 946 | if ( '' != $this->lang ) { |
| 947 | + $this->printDebug( "Setting language.", NONSENSITIVE ); |
909 | 948 | $user->setOption( 'language', $this->lang ); |
910 | 949 | } |
911 | 950 | if ( '' != $this->nickname ) { |
| 951 | + $this->printDebug( "Setting nickname.", NONSENSITIVE ); |
912 | 952 | $user->setOption( 'nickname', $this->nickname ); |
913 | 953 | } |
914 | 954 | if ( '' != $this->realname ) { |
| 955 | + $this->printDebug( "Setting realname.", NONSENSITIVE ); |
915 | 956 | $user->setRealName( $this->realname ); |
916 | 957 | } |
917 | 958 | if ( '' != $this->email ) { |
| 959 | + $this->printDebug( "Setting email.", NONSENSITIVE ); |
918 | 960 | $user->setEmail( $this->email ); |
919 | 961 | } |
920 | 962 | if ( ( isset( $wgLDAPUniqueBlockLogin[$_SESSION['wsDomain']] ) && $wgLDAPUniqueBlockLogin[$_SESSION['wsDomain']] ) |
— | — | @@ -925,6 +967,8 @@ |
926 | 968 | } |
927 | 969 | |
928 | 970 | $saveSettings = true; |
| 971 | + } else { |
| 972 | + $this->printDebug( "WTF!?", NONSENSITIVE ); |
929 | 973 | } |
930 | 974 | |
931 | 975 | if ( isset( $wgLDAPUseLDAPGroups[$_SESSION['wsDomain']] ) && $wgLDAPUseLDAPGroups[$_SESSION['wsDomain']] ) { |
Index: trunk/extensions/LdapAuthentication/AutoAuthentication.php |
— | — | @@ -66,6 +66,8 @@ |
67 | 67 | $user->setID( $localId ); |
68 | 68 | $user->loadFromId(); |
69 | 69 | $user->setCookies(); |
| 70 | + $wgAuth->updateUser( $user ); |
| 71 | + wfSetupSession(); |
70 | 72 | $result = true; |
71 | 73 | } |
72 | 74 | |
— | — | @@ -88,6 +90,7 @@ |
89 | 91 | |
90 | 92 | $wgAuth->initUser( $user, true ); |
91 | 93 | $user->setCookies(); |
| 94 | + wfSetupSession(); |
92 | 95 | |
93 | 96 | # Update user count |
94 | 97 | $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |