get username from active directory in C#.net [closed]
- by Jahangeer Ahmed
get username from active directory in C#.net
ManagementObjectSearcher Usersearcher = new ManagementObjectSearcher("Select * From Win32_ComputerSystem");
ManagementObjectCollection Usercollection = Usersearcher.Get();
string[] sep = { "\" };
string[] UserNameDomain = Usercollection.Cast().First()["UserName"].ToString().Split(sep, StringSplitOptions.None);
null reference exception