Is there a way to get a list of roles a Windows authenticated user is in, without explicitly checking by WindowsPrincipal.IsInRole method?
Is there a way to get a list of roles a Windows authenticated user
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
WindowsPrincipal.IsInRolejust checks if the user is a member of the group with that name; a Windows Group is a Role. You can get a list of the groups that a user is a member of from theWindowsIdentity.Groupsproperty.You can get
WindowsIdentityfrom yourWindowsPrincipal:or you can get it from a factory method on WindowsIdentity:
WindowsIdenity.Groupsis a collection ofIdentityReferencewhich just gives you the SID of the group. If you need the group names you will need to translate theIdentityReferenceinto anNTAccountand get the Value: