Ahmad Farid
Ahmad Farid

Reputation: 14764

determine the user on SharePoint

How can I know the user logging onto SharePoint through code? I am using WebPart inside it SmartPart and inside it a User control.

Upvotes: 0

Views: 139

Answers (2)

Jeff Widmer
Jeff Widmer

Reputation: 4876

I am assuming your SharePoint site is running under Windows Authentication (which most would be). In that case you can get the current user name using:

System.Web.HttpContext context = System.Web.HttpContext.Current;
string username = context.User.Identity.Name;

Upvotes: 0

Timothée Martin
Timothée Martin

Reputation: 773

You can get the user informations with :

SPContext.Current.Web.CurrentUser

Here are some informations like email, ID, Groups, Name... Type Ctrl + Space ;)

Hope it helps...

Upvotes: 4

Related Questions