DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

获å?–当å‰?登陆用户的登陆å??

10.15.2006
| 1937 views |
  • submit to reddit
        // description of your code here

http://support.microsoft.com/default.aspx?scid=kb;zh-CN;832769
//获å?–当å‰?登陆用户的登陆å?? 
WindowsPrincipal wp = (WindowsPrincipal)Thread.CurrentPrincipal; 
string wpname = wp.Identity.Name.ToString(); 
int j = wpname.LastIndexOf("\\"); 
string userName = wpname.Substring(j+1); 
string domainName = wpname.Substring(0,j);