1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Connecting the Login Control to a custom database?

Discussion in 'C#' started by WayTooAwesome, Jun 30, 2006.

  1. #1
    Hey, I'm back again with more nublet questions! <3

    Here's my problem:

    I have a database with a single table that's loaded with information, and each row represents a single person that database. I have several different pages in my site already that basically display the information about each person in a variety of ways (A manager/employee hierarchy, search function, etc).
    However, where I'm stuck is at the capability of allowing these several different people/users to log in and change their own information within the database. I've added a username and password column and given each person values for them, but I can't figure out how to connect the login control to them.

    If I use the default control, it wants me to either manually create all of the users in roles and groups (Which won't work because I need to be able to get Joe Manager or whoever the capability of adding whole new people to the database), or use Windows Authentication (Which I can't do because it's over the internet).

    I've looked up some stuff on the internet and have tried changing my web.config file, but if that is the answer, I don't know how to direct it to the username/password fields in my database. Can I even go through the built-in login control? Do I have to change the web.config file? Am I making this way more difficult than it needs to be? ^_~ It just sounds like it'd be a no brainer to be able to connect a login control to a couple fields in a database... >_>

    (I'm not entirely sure what kind of database I'm using... Just whatever the default is in Visual Studio 2005, so I'd imagine MSSQL. Also, I'm using C#, so that's preferred, but I found a nifty VB -> C# converter thing that I can use if I have to.)

    WayTooAwesome, Jun 30, 2006 IP
  2. benjymouse

    benjymouse Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    VS2005 comes with Sql Server 2005 Express Edition - so that's what you're using.

    ASP.NET also comes with a default "membership provider" which assumes a certain layout of user tables in an Sql Server 2005 database.

    If for some reason (like an already existing user database) you cannot do with the builtin membership provider, you can write your own.

    See this article. You'll have to implement some 25 methods/properties, most of which are really simple (like always return true or always return false)

    If you do this, you will also need to change the web.config file to use your custom membership provider. This is quite simple, and also explained in the article.

    The benefit is that you can use all of the builtin controls for creating new users, logging in/out, displaying conditional contents, retrieving lost passwords etc.
    benjymouse, Jul 3, 2006 IP