Getting the current login name from SharePoint

Hi guys,

Recently I was creating a Web Part and I needed to get hold of the current login name for comparison. It was simple and didn’t require great amounts of code. Thanks you
SharePoint for making life easier.   Laughing 

string userName = SPContext.Current.Web.CurrentUser.LoginName;

Returns
domain\LoginName

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



 

Dilbert of the day