Ermittelt die aktuelle Benutzerrolle, und
gibt einen Klartext der Benutzerrolle zurück.
/// <summary>
/// Gibt einen String mit der Beschreibung der aktuellen Benutzerrolle zurück.
/// </summary>
/// <returns></returns>
private string GetUserRole()
{
WindowsIdentity Identity = WindowsIdentity.GetCurrent();
WindowsPrincipal wp = new WindowsPrincipal(Identity);
if (wp.IsInRole(WindowsBuiltInRole.AccountOperator))
return "Account Operator";
else if (wp.IsInRole(WindowsBuiltInRole.Administrator))
return "Administrator";
else if (wp.IsInRole(WindowsBuiltInRole.BackupOperator))
return "Backup Operator";
else if (wp.IsInRole(WindowsBuiltInRole.Guest))
return "Guest";
else if (wp.IsInRole(WindowsBuiltInRole.PowerUser))
return "Power User";
else if (wp.IsInRole(WindowsBuiltInRole.PrintOperator))
return "Print Operator";
else if (wp.IsInRole(WindowsBuiltInRole.Replicator))
return "Replicator";
else if (wp.IsInRole(WindowsBuiltInRole.SystemOperator))
return "System Operator";
else if (wp.IsInRole(WindowsBuiltInRole.User))
return "User";
return "unknown";
}
1 Kommentare zum Snippet