为什么我在RunWithElevatedPrivileges域\ apppool中获得i:0#.w | domain \\ username?

STO*_*ORM 3 c# sharepoint sharepoint-2013

当我做

Console.WriteLine(SPContext.Current.Web.CurrentUser.LoginName);
Run Code Online (Sandbox Code Playgroud)

我得到以下回应:

i:0#.w|domain\\username
Run Code Online (Sandbox Code Playgroud)

当我做

SPSecurity.RunWithElevatedPrivileges(delegate() {
    Console.WriteLine(SPContext.Current.Web.CurrentUser.LoginName);
});
Run Code Online (Sandbox Code Playgroud)

我得到

domain\appPoolAccount
Run Code Online (Sandbox Code Playgroud)

i:0#.w|登录名中没有...。

有人能够解释为什么会这样吗?

Ver*_*osa 5

用户名之前的前缀(i:0#.w |)只是一个内部代码,以便SharePoint可以标识身份验证的类型(w:Windows auth,f:基于表单等)。代码中的i用来标识它是用户。仅供参考,如果您尝试写出一个组,则前缀为c而不是i。

您在提升权限中没有前缀的事实是,它将始终是admin / pool-account,它将始终是Windows用户-因此无需添加前缀...

  • 我的猜测是您的 2010 机器仅配置为使用 Windows 身份验证?我不确定,但我想引导您访问此链接,该链接对声明前缀进行了详尽的解释:http://www.wictorwilen.se/Post/How-Claims-encoding-works-in-SharePoint-2010.aspx (2认同)