【问题标题】:Why does HttpContext.Current.User.Identity.Name return the wrong username when used in a webpart?为什么 HttpContext.Current.User.Identity.Name 在 Web 部件中使用时返回错误的用户名?
【发布时间】:2010-12-18 06:51:21
【问题描述】:

在 Sharepoint 网页中,我在识别登录用户时遇到问题!

Masterpage 包含一个显示用户名的普通 ootb 控件

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

这总是显示正确的登录用户。

但是如果我打电话给

HttpContext.Current.User.Identity.Name

从 webpart 中,然后在 1% 或 2% 的情况下,我会得到不正确的名称返回。

这给了我一个页面,该页面的顶部有正确的用户名,而 webpart 中的用户名不正确。在 Web 部件中获取名称的其他方法返回相同的错误名称。如果名称检查器 Web 部件多次出现在同一页面上,那么该 Web 部件的第二个副本很少会具有正确的名称或第三个不正确的身份!

身份存储在 Active Directory 中,用户通过 ISA 服务器进行身份验证,用户与 SharePoint 基础架构不在同一个域中。共享点场相当复杂,包含 ISA 服务器、四个 Web 前端、一个应用程序服务器,最后是一个数据库服务器。

以前有人遇到过这种情况吗?或者对我应该采取的调查问题的方向有任何线索!

服务器在服务器 2003 上运行 IIS6。Sharepoint 处于 SP2,但没有最新的补丁。

补充: 输出缓存已启用。经过身份验证的缓存配置文件是“Intranet” 该配置文件的设置如下

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)        

【问题讨论】:

  • 用户控件是OutputCached?

标签: sharepoint iis identity


【解决方案1】:

SharePoint 在应用程序池帐户下运行。你需要使用 SPContext.Current.Web.CurrentUser.LoginName 获取当前用户。

【讨论】:

  • 这给了我们与直接访问 HttpContext 相同的错误用户。
【解决方案2】:

这是不久前的事了,很抱歉没有报告我们的解决方案……现在我记不清是什么了!与我们误解的甜甜圈缓存有关。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-22
    • 2019-12-08
    相关资源
    最近更新 更多