Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the logged in user in Sharepoint?

I have developed a "web part" that has to be deployed on a Sharepoint server. I need the username of the user, who has logged in the sharepoint server within the web part.

How do I get that username?

like image 727
Brigadier Jigar Avatar asked Mar 11 '10 07:03

Brigadier Jigar


1 Answers

Following worked for me:

SPWeb theSite = SPControl.GetContextWeb(Context);
SPUser theUser = theSite.CurrentUser;
string strUserName = theUser.LoginName;

and check this out.

like image 62
KMån Avatar answered Sep 21 '22 12:09

KMån