Hallo
Ich möchte das etwa wie folgt lösen, nur funktioniert das nicht.
Kann mir wer zeigen, was ich falsch mache oder wie man es besser lösen könnte
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
| private static string getRole() { string role = String.Empty;
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsPrincipal windowsPrincipal = (Thread.CurrentPrincipal as WindowsPrincipal);
try { switch (windowsPrincipal.IsInRole) { case WindowsBuiltInRole.Administrator: role = "Admin"; break; case WindowsBuiltInRole.User: role = "User"; break; }
} catch (Exception exception) { Console.WriteLine(exception.Message); } return role; |
Danke
Metrik