4

I am getting user roles from Active Directory and I am binding the same roles to ASP.NET Membership Roles.

I want to control the display for the various Views in Controller by using

[Authorize(roles="Admin")]

But Which ever role I specify, The View just doesn't display. If I take out the [Authorize(roles="Admin")] it works.

Does Authorize uses ASP.NET Membership roles? if so, Why I am getting this error?

Am I missing anything? Any Ideas?

Thank you

Mahesh Velaga
  • 21,633
  • 5
  • 37
  • 59
Hari Gillala
  • 11,736
  • 18
  • 70
  • 117

2 Answers2

5

IIRC if you use AD roles it works with groups and you need to specify the domain:

[Authorize(Roles = @"MYDOMAIN\SomeDomainGroup")] 

Now if the user accessing the site belongs on the given AD group he will be granted access.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • @Hari Gillala, my point is that the `Role` property is used with AD groups. So you should specify the AD group that you want to grant access to. – Darin Dimitrov May 27 '11 at 15:47
  • I tried with [Authorize(Roles = @"Domainname\groupname")], Nothing gets displayed. If I take out the attribute [Authorize] then it works but there is no point for me to do that. I don't know why its behaving in this format. – Hari Gillala May 27 '11 at 16:11
  • So you must limit you application to only ever working on the specified domain, or you must write your own Authorize attribute that checks the name of the group only. – Russell Horwood Apr 03 '14 at 11:20
0

Assuming you are using the VS built in server and you are getting a blank page - the built in development server will display a blank page instead of prompting for credentials.

Buried way down in a note on this page

Note:
If you are using the Visual Studio Development server, you are not prompted for credentials and you see only a blank page.
Geoff
  • 3,749
  • 2
  • 28
  • 24