Last post Jan 15, 2013 04:09 AM by Angie xu - MSFT
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.
Jan 15, 2013 04:09 AM|Angie xu - MSFT|LINK
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)
hope it helps you,