In some instances of WSS or MOSS when you use the "Sign in as Different User" option, the new login doesn't "take". Is there any known issue here? Usually logging out and then logging back in with the second user does work. This seems like a pretty big problem and I've seen it on and off over the years, mostly while testing with different identities.
UPDATE 1: I'm seeing it in several hosted WSS situations, so I don't actually know what authentication they are using. Interestingly, I don't see it in some hosted WSS situations, too. And consistently within the instance. This might tell us that the authentication method might matter.
UPDATE 2: Another piece of info I should have included in the first place: The reason that I'm asking this is that the $().SPServices.SPGetCurrentUser in SPServices sometimes returns the previous user. All I'm doing in that function is loading the _layouts/userdisp.aspx?Force=True page and pulling the Name from the page. It's the column with the label 'Account', but the InternalName is 'Name':
<!-- FieldName="Account"
FieldInternalName="Name"
FieldType="SPFieldText"
-->
Here's the SPServices function:
// Function which returns the account name for the current user in DOMAIN\username format
$.fn.SPServices.SPGetCurrentUser = function() {
var username = "";
$.ajax({
async: false, // Need this to be synchronous so we're assured of a valid value
url: $().SPServices.SPGetCurrentSite() + "/_layouts/userdisp.aspx?Force=True", // Force parameter forces redirection to a page that displays the information as stored in the UserInfo table rather than My Site.
complete: function (xData, Status) {
$(xData.responseText).find("table.ms-formtable td#SPFieldText").each(function() {
if(/FieldInternalName=\"Name\"/.test($(this).html())) username = $(this).text();
});
}
});
return username.replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');
};
One would like to think that this page would always represent the currently logged in user, but sometimes it represents the prior user. Not good.
UPDATE 3: I may have come up with a fix for this in my SPServices library, at least. It doesn't solve the larger problem that SharePoint seems to have, though. I added a unique Query String parameter (just the current time) to the call to userdisp.aspx in SPGetCurrentUser per arunduttgp's suggestion. This seems to force the browser to do a hard refresh on the page in the AJAX call, getting the correct values for the logged in user even when the current SharePoint page is showing the prior user incorrectly.
url: $().SPServices.SPGetCurrentSite() + "/_layouts/userdisp.aspx?Force=True&" + new Date().getTime(),