Search code examples
.netvb.netactive-directoryldapasp.net-membership

.net active directory (ldap) authentication with membership authorization


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?


Solution

  • 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