Search code examples
asp.net-mvcauthenticationsimplemembership

SimpleMembership with stored procedures


Our DBA requires access to our database (MSSQL server) using stored procedures only (no direct access to tables). Is it possible to use ASP.NET SimpleMembership with stored procedures? If not, is there other way how to implement security in MVC project with this constraint? Thanks


Solution

  • You can create a custom SimpleMembershipProvider and SimpleRoleProvider that calls the stored procedures your DBA provides. You will need to rip out the initialization process out of the MVC 4 Internet template as discussed in this article, and add your own initialization if required. To plug in your custom providers into your application modify the web.config to something like this:

    <add name="SimpleMembershipProvider" type="MyCustomMembershipProvider.SimpleMembershipProvider, MyCustomMembershipProvider"/>
    

    Where MyCustomMembershipProvider is the name of the assembly that contains your implementation of SimpleMembershipProvider. Do the same for your role provider.