Click here to Skip to main content
15,896,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is the first time I have work with Role-based Security.

I have created all my web pages setup the permission on all pages.

set roles
register test user

for the different groups

all pages are responding perfectly

But now I need to connect the user with the database I created.

1. How can I use the ASP.NET Membership with my own database.

If you can either help by giving sample code.

Or point me to the right links/Articles.

Thanks
Posted

All you have to do is implement a custom MemberShip provider, and reference that in your web.config - there is a link here, but it looks a bit more complex than the one I remember when I last did it! http://msdn.microsoft.com/en-us/library/aa479048.aspx[^] It is probable Google could find you a simpler tutorial - it isn't at all difficult, it's mostly a case of implementing your provider based on the MembershipProvider class, then changing web.config:
XML
<membership defaultProvider="SMMembershipProvider" userIsOnlineTimeWindow="15">
  <providers>
    <add
      name="SMMembershipProvider"
      type="SMProvider.SMMembershipProvider"
      connectionStringName="OdbcServices"
      enablePasswordRetrieval="false"
      enablePasswordReset="false"
      requiresQuestionAndAnswer="false"
      writeExceptionsToEventLog="true" />
  </providers>
</membership>
 
Share this answer
 
Thanks, I solve it.

I change my web.config file:

<connectionstring>
<add name="somename" connectionstring="Datasource=server;Database=change to your database;uid=name;pwd=password;" provdername="What every provider you are going use" />
</connectionstring>


I am using MySQL, In visual studio 2010 I click the ASP.NET Configuration link.
It installed the Membership, Role and User information in my custom database.

So I am creating foreign keys and stored routine.

I have a MySQL version and SQL Server versions. This works on both.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900