There are several built in roles to help determine if the user is an Admin, User or Guest.
WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
WindowsPrincipal currentPrincipal = newWindowsPrincipal(currentIdentity);
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
if (currentPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
{
//Administator code
}
if (currentPrincipal.IsInRole(WindowsBuiltInRole.User))
{
// User code
}
// User code
}
if (currentPrincipal.IsInRole(WindowsBuiltInRole.Guest))
{
// Guest or anonymous code
}
// Guest or anonymous code
}
No comments:
Post a Comment