I see all kinds of code to get current SharePoint 2010 logged in user. (I guess current context user from the browser client).

What is the best code? (not currently logged into machine user)

  • What is it that you are trying to do and from where? For example, the code for a web part is radically different from a powershell script which is also different from what you would use in a timer job – Dave Wise Apr 19 '12 at 16:19

Use SPContext.Current.Web.CurrentUser will give you the current user SPUser object (browser). To get the current user loginname use SPContext.Current.Web.CurrentUser.LoginName .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.