Welcome to MSDN Blogs Sign in | Join | Help

Determining the Current User Context inside Sharepoint

What's the best way to determine the current user within a custom web part
developed for MOSS 2007?  I've found four solutions so far, but I'm pretty sure
there are more:

1. Use System.Web.HttpContext.Current.User.Identity.Name, like in any 
    ASP.Net web application


2. Use System.Security.Principal.WindowsIdentity.GetCurrent().Name


3. Have the Current User Filter send the current user to your web part,
    and (of course) make your web part a consumer of that value.

4. SPWeb web = SPControl.GetContextWeb(Context); 
    SPUser currentUser = web.CurrentUser;
Published Tuesday, April 01, 2008 5:08 AM by Madhur

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Links (4/1/2008) « Steve Pietrek’s SharePoint Stuff

Tuesday, April 01, 2008 9:08 PM by Links (4/1/2008) « Steve Pietrek’s SharePoint Stuff

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker