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|登录名中没有...。
有人能够解释为什么会这样吗?
用户名之前的前缀(i:0#.w |)只是一个内部代码,以便SharePoint可以标识身份验证的类型(w:Windows auth,f:基于表单等)。代码中的i用来标识它是用户。仅供参考,如果您尝试写出一个组,则前缀为c而不是i。
您在提升权限中没有前缀的事实是,它将始终是admin / pool-account,它将始终是Windows用户-因此无需添加前缀...
| 归档时间: |
|
| 查看次数: |
7606 次 |
| 最近记录: |