得到当前用户的几种办法

     在有些时候,我们需要知道登录当前页面的用户是谁,下面是几个使用过的方法,也有从网上搜刮来的。

1.

ContractedBlock.gif ExpandedBlockStart.gif Code
SPWeb web = SPControl.GetContextWeb(Context); 
SPUser currentUser 
= web.CurrentUser; 
2.
ContractedBlock.gif ExpandedBlockStart.gif Code
System.Security.Principal.WindowsIdentity.GetCurrent().Name //这个是从网上搜刮来的
3.
ContractedBlock.gif ExpandedBlockStart.gif Code
System.Web.HttpContext.Current.User.Identity.Name
大家要是有什么其它的办法,也来分享一下。

转载于:https://www.cnblogs.com/jdxyw/archive/2008/11/27/1342025.html

你可能感兴趣的:(得到当前用户的几种办法)