Seth
Seth

Reputation: 8373

Can I just implement RoleProvider without MembershipProvider?

I am developing an intranet application with Windows Authentication, I have implemented a custom role provider and tied that in with my repository which has Users and Roles.

I use [Authorize(Role="Administrator")] on my controller class. I am logged in as "UserA", and I have implemented GetRolesForUser(string username). Additionally, "UserA" is an "Administrator" role however Authorization still seems to fail.

Do I still have to implement the MembershipProvider?

Upvotes: 0

Views: 250

Answers (2)

Rahul Ranjan
Rahul Ranjan

Reputation: 1058

Yes,you can implement Role-provider without Membeship Provider definitely...

If you're looking to write a role provider, use the existing role provider code for a starting point or learning exercise. Get it from..

Role ProviderToolKitSamples

Upvotes: 0

jrummell
jrummell

Reputation: 43087

Windows Authentication does not require a MembershipProvider. You can use any RoleProvider you want.

One thing to check in your role provider is how the username is stored. The Windows Authentication identity is DOMAIN\UserName. Make sure your role provider stores usernames in the same format.

Upvotes: 1

Related Questions