mikeds
mikeds

Reputation: 187

Get current sharepoint user id inside a web part

I am trying to access the currently logged in user when an event fires in a web part. I would typically think to do this with:

SPContext.Current.Web.CurrentUser

and specifically, to get the ID (what I need):

SPContext.Current.Web.CurrentUser.ID

This works as expected in say an event receiver. However, in my example web part, this is returning information about the machine user account. How would I best access the logged in SharePount user instead?

Upvotes: 2

Views: 3515

Answers (1)

mikeds
mikeds

Reputation: 187

I figured it out. When debugging I was logged in as the system account which messed things up. Using a regular user account presented the expected results using the methods above.

Upvotes: 1

Related Questions