views:

617

answers:

2

In a Sharepoint web page I am having a problem identifying the logged in user!

The Masterpage contains a normal ootb control that displays the username

<%@ Register TagPrefix="wssuc" TagName="Welcome" Src="~/_controltemplates/Welcome.ascx" %>
.....
.....
<wssuc:Welcome id="explitLogout" runat="server" />

This always displayed the correct logged on user.

However if I call

HttpContext.Current.User.Identity.Name

from within a webpart then In 1 or 2 % of cases I will get the incorrect name returned.

This gives me a page that will have the correct username at the top, and the incorrect one in the webpart. Other methods of getting the name in the webpart return the same incorrect name. If the name checker webpart is on the same page multiple times then very rarely the second copy of the webpart will have the correct name or a third incorrect identity!

The identities are stored in Active Directory, and the users authenticate against and ISA server, users are not on the same domain as the SharePoint infrastructure. The sharepoint farm is rather complex with the ISA servers, four web front ends, an apps server and finally a database server.

Has anyone had this happen before? or have any clue as to the direction I should take to investigate the problem!

The servers are running IIS6 on server 2003. Sharepoint is at SP2 but without the latest bunch of patches.

Additional: Output Cache is enabled. Authenticated Cache Profile is "Intranet" The settings for that profile are as follows

Title                       Intranet (Collaboration Site) 
Display Name                  (BLANK)
Display Description     Optimized for collaboration sites where authoring, web part cusomization, and minor version are enabled. 
Perform ACL Check       Yes 
Enabled                 Yes 
Duration                180 
Check for Changes       Yes 
Vary by Custom Parameter      (BLANK)    
Vary by HTTP Header     Browser 
Vary by Query String Parameters     (BLANK)      
Vary by User Rights     Yes 
Cacheability            ServerAndPrivate 
Safe for Authenticated Use  Yes 
Allow writers to view cached content   (BLANK)
+1  A: 

SharePoint runs under the application pool account. You need to use SPContext.Current.Web.CurrentUser.LoginName to get the current user.

KoenVosters
That gives us the same wrong user as going straight for the HttpContext.
Aidan
A: 

We are having the same issue. Did you figure out the problem?

NewUser
Not completely. It is something to do with the output cache and investigating donut caching may help you.
Aidan