is in group?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys

I'm using Windows Auth and want to check that the logged in user is part of
a specific group in order to limit access to some part of the site.

How do I do this?

Cheers


Dan
 
You can use

Page.User.IsInRole(@"DomainName\GroupName");

HTH

Elton Wang
(e-mail address removed)
 
Elton,

Thanks for that. Unfortunately it doesnt seem to work.

ive tried the following code..

if(Page.User.IsInRole(role))
btnNewProject.Disabled = false;
else
btnNewProject.Disabled = true;

Where role is "mydomain.com\TestGroup" and the logged in user is a member of
TestGroup. When I run the code, the button is always disabled! Am I missing
something?!

Cheers


Dan
 
In order to use User object, you have to deny anonymous
access. Otherwise, it doesn't work.

HTH

Elton Wang
 
Hello Elton,

Your statement is incorrect. I think what you meant to say was:

In order to use the User object to retrieve Active Directory roles, anonymous
access must be disabled. You can absolutely use the User object when using
anonymous access (ie: FormsAuthentication).
 
Back
Top