How can I know the user logging onto SharePoint through code? I am using WebPart inside it SmartPart and inside it a User control.
+4
A:
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...
Timothée Martin
2009-07-24 09:34:05
Thanks a lot man :) That's exactly what I was looking for.
Ahmad Farid
2009-07-24 09:38:20
A:
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;
Jeff Widmer
2009-07-24 09:36:13
You can directly access to the SharePoint HttpContext with SPContext :)
Timothée Martin
2009-07-24 09:37:50