Showing posts with label SPUser. Show all posts
Showing posts with label SPUser. Show all posts

Monday, May 07, 2012

current user in sharepoint

Trimmed lines of code to get the currently logged in user details in SharePoint
 public SPUser GetCurrentUser()
        {
            var context = SPContext.Current;
            SPWeb web = context.Web;
            return web.CurrentUser;
        }

After you getting the SPUser object you can retrieve the login name,email,first name and last name of this user.