Thursday, August 9, 2012

Getting the current user's domain + account name in MVC 3

Quick and easy one (now that I've found it out) - prior to using MVC 3, I was using User.Identity.Name to get the current user's name.  But since moving to MVC 3, that property was returning blank.

Discovered the correct way to do this is simply:

Environment.UserDomainName + "\\" + Environment.UserName

This will happily return DOMAIN\accountname.  Easy when you know how...

No comments:

Post a Comment