1
votes

I am trying to create a hybrid membership which authenticates with active directory (ldap) but authorizes using the membership provider and roles.

I do not want to query active directory for each page load, but I want to initially authenticate the user via active directory, and then allow the membership provider to authorize the users access to each page via the web.config authorization properties.

I am new to the .net membership model and how to implement this type of hybrid solution. I have found many examples for implementing Active Directory with Web Forms, but not a solution to my needs.

Any pseudocode or general description for this solution is also very welcome.

Thank you!

UPDATED Question: Currently looking into implement the active directory (AD) authentication on top of the Membership/Roles schema. Basically authenticating initially with AD, updating the Membership database tables with the user/roles as needed, setting the user as authenticated with the Membership and allowing the membership to handle all authorization requirements. Although this is not as clean as creating Custom Membership/Role providers, I am wondering if this solution can be considered valid?

2
Honestly, if you're new to the .net world, this may be a big bite to chew initially. It can be done, but you'll certainly want to familiarize yourself with the Membership Provider implementation. You'll get much better feedback from this community if you scale your question down quite a bit and ask specific questions related to the process.Nick DeVore

2 Answers

0
votes

I would recommend using NTLM to retrieve the current windows domain username and use it to pre-populate your form's username field. Once the user enters their password and completes authentication to your app, run an LDAP query against active directory. Log them out with a friendly message if AD authentication fails.

Unfortunately, there is way too much code needed for me to post on this one answer.

0
votes

You can do this by implementing your own layer above the Membership provider by doing the following

  1. you need to check if the user authenticated in the active directory
  2. after that you will need to add this user if he doesn't exist to your Membership database and Roles and use this later on for controlling the use roles and other stuff
  3. after that you can begin setting an authentication cookie for this user(if the user is valid) and add it to the response.
  4. every time an authenticated user will request a page you wouldn't need to validate him against the active directory, you will need to do so just for anonymous users.

its a lot of work but you can do it, after all you just need to read more about Asp.net membership