SPContext.Current.Web.CurrentUser 返回误导性值 [英] SPContext.Current.Web.CurrentUser returns misleading value

查看:56
本文介绍了SPContext.Current.Web.CurrentUser 返回误导性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出我的 sharepoint 应用程序的当前用户名.还有更多的方法可以做到这一点.但是,sharepoint 方式会返回误导性值.

I'm trying to find out current user name for my sharepoint application. There are more that one way how to do this. However the sharepoint way returns misleading value.

System.Security.Principal.WindowsIdentity.GetCurrent().Name // returns MY_COMPUTER\\my_user

HttpContext.Current.User.Identity.Name // returns MY_COMPUTER\\my_user

HttpContext.Current.Request.ServerVariables["AUTH_USER"] // returns MY_COMPUTER\\my_user

Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.LoginName // returns SHAREPOINT\\system

这种行为的原因是什么?如果我使用非共享点方式,我会遇到问题吗?

What is the cause of this behavior? Will I encounter problems if I'll use non-sharepoint way?

推荐答案

如果用户是运行当前 Web 应用程序的应用程序池帐户,这是预期的.
顺便说一句,它应该与欢迎控件(左上控件)中显示的名称相同

This is expected if the user is the application pool account running the current web application.
BTW, it's supposed to be the same name as displayed in the welcome control (upper left control)

这篇关于SPContext.Current.Web.CurrentUser 返回误导性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆