Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)

share|improve this question
    
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
add comment

1 Answer 1

up vote 0 down vote accepted

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 .

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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