开发者

Why does HttpContext.Current.User.Identity.Name return the wrong username when used in a webpart?

开发者 https://www.devze.com 2022-12-12 12:25 出处:网络
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

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 na开发者_高级运维me 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)        


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


This was a while ago and I am sorry for not reporting back our solution... and now I don't remember clearly what it was! Something to do with Donut Caching that we had misunderstood.

http://blogs.catapultsystems.com/tlingenfelder/archive/2011/03/24/sharepoint-caching-techniques.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号