Hi, I have an asp.net application which is able to authenticate against Windows active directory. That part works fine. When a certain user logs in, I want him to be able to check if another user is in a certain role/group.
I tried using Role.IsUserInRole(String username, String rolename) but the application throws an error saying that the current user can only check if the current user is in a role/group. If that is so, then would be the point of the first parameter of this
method if the only user that can be checked is only the current user? So it looks like the first parameter will always need to be "User.Identity.Name".
Is there an easy way for the current user to check if another user is a member of a role/group? If it isn't a simple task, can you point me in the right direction, since I haven't really done this before. Thanks in advance.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
7 Points
155 Posts
How to check roles/groups of other users (not current user) ?
Jan 09, 2013 02:16 PM|S2kDriver|LINK
Hi, I have an asp.net application which is able to authenticate against Windows active directory. That part works fine. When a certain user logs in, I want him to be able to check if another user is in a certain role/group.
I tried using Role.IsUserInRole(String username, String rolename) but the application throws an error saying that the current user can only check if the current user is in a role/group. If that is so, then would be the point of the first parameter of this method if the only user that can be checked is only the current user? So it looks like the first parameter will always need to be "User.Identity.Name".
Is there an easy way for the current user to check if another user is a member of a role/group? If it isn't a simple task, can you point me in the right direction, since I haven't really done this before. Thanks in advance.
All-Star
32817 Points
3815 Posts
Re: How to check roles/groups of other users (not current user) ?
Jan 15, 2013 04:09 AM|Angie xu - MSFT|LINK
Hi S2kDriver
I think Roles.IsUserInRole Method (String, String) method and WebSecurity.UserExists( ) method are available for you,
if ((WebSecurity.UserExists( ) ) && (Roles.IsUserInRole(String username, String rolename)))
You could also refer the usage of Roles.IsUserInRole Method (String, String) method and WebSecurity.UserExists( ) method below,
Roles.IsUserInRole Method (String, String)
WebSecurity.UserExists Method
hope it helps you,
Kind regards
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.