Reputation: 14764
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
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
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