How to get information of User?
-
string mystring = Environment.UserName; As for the group: I have no clue. Try Win32-API or find out if it is in here: class Sample // MSDN-Sample { public static void Main() { Console.WriteLine(); Console.WriteLine("GetEnvironmentVariables: "); IDictionary environmentVariables = Environment.GetEnvironmentVariables(); foreach (DictionaryEntry de in environmentVariables) { Console.WriteLine(" {0} = {1}", de.Key, de.Value); } } } // MSDN-Sample
-
If you want to find out if a user is a particular known group you can use... WindowsIdentity wi = WindowsIdentity.GetCurrent(); WindowsPrincipal wp = new WindowsPrincipal(wi); wp.IsInRole("Administrator"); //or whatever the role is. Getting a list of Groups a user is a member of is more difficult the last time I needed to do it I used the WinNT ADSI provider with the DirectoryServices classes... ----------------------------------------------------------------------- Shaun Austin: .NET Specialist. Spreading the word of .NET to the world... well the UK... well my tiny corner of it!! :-D