Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

ASP.NET Logins

 

I've just watched a few great video's off http://www.ASP.NET, but they raised a few questions.

 

The example view of logins (which was what i was originally trying to find out) seemed to store the logins within the ASP server somehow. I want mine stored in an SQL database. Does anyone please have any examples of how to do this?

 

Thanks

Jay.

Edited by Jay1b
Posted

Just to go into a little more detail.

 

I can use the login controls no problem, but could someone please tell me where are the usernames and passwords stored for the various users stored?

 

Is it possible to use to use these with a database? ie: I want a users_t table, which stores all the usernames and passwords and the login control to check this table to decide upon database access. We use a users_t facility with all our other databases and would like to continue doing so.

 

Thanks

 

Jay.

  • Administrators
Posted

The default implementation stores them inside a SQLExpress database, if you want to use the default schema but on another DB then the utility aspnet_regsql.exe can be used to configure a given SQL server.

 

If you do this you will need to alter the web.config to point to the new DB.

 

If you wish to use a different security mechanism then you would need to create your own RoleProvider and MembershipProvider classes by inheriting from the ones provided in System.Web.Security (or near there anyway).

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Thanks for you help (once again).

 

I researched the aspnet_regsql.exe online, and found an interesting article at :

http://msdn2.microsoft.com/en-us/library/x28wfk74(vs.80).aspx

 

But i cant find anything with regards to changing the web.config file to read this database. I've opened the database i assigned it to, and i can see the generated tables ok, so i know that bit works ok. But i just need to tie it into the project.

 

Thanks again.

Posted
Thanks, I'm sure it gives me all the information, but to be honest i think i'm a little out of my depth here. I can find information on writing your own role and membership providers, but as i've decided not to write my own security mechanisms now (its to scary!). I just need to get the project to look at a different database, and thats the only part i cant find mentioned within the link. :(
  • Administrators
Posted

Something like


        name="ExampleConnectionString" 
     connectionString="your connection string here" providerName="System.Data.SqlClient" />



    defaultProviderAspNetSqlRoleProvider">

              name="AspNetSqlRoleProvider" 
        type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />



    defaultProvider="AspNetSqlMembershipProvider">
   
             name=" AspNetSqlMembershipProvider"
       type="System.Web.Security.SqlMembershipProvider, System.Web, 
         Version=2.0.3600.0, Culture=neutral, 
         PublicKeyToken=b03f5f7f11d50a3a"
       connectionStringName="ExampleConnectionString"
     />
   
 

 

not tested it (it's a hacked version of one I have used - names removed etc)

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Thank you very very much :)

 

I managed to derive this below, which seems to work :)

 

I dont understand why the user information is being saved into the database though, when the user isnt mentioned? :S

 

------------------------------------------------------------------

<?xml version="1.0"?>

<!--

Note: As an alternative to hand editing this file you can use the

web admin tool to configure settings for your application. Use

the Website->Asp.Net Configuration option in Visual Studio.

A full list of settings and comments can be found in

machine.config.comments usually located in

\Windows\Microsoft.Net\Framework\v2.x\Config

-->

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

 

 

<appSettings/>

<connectionStrings>

<add

name="ExampleConnectionString"

connectionString="Data Source=RA\SQLExpress;Initial Catalog=CReq;User ID=sa;Password=sisko9"

providerName="System.Data.SqlClient" />

</connectionStrings>

 

<system.web>

 

<authentication mode="Forms" />

<roleManager defaultProvider="SqlProvider" enabled="true">

<providers>

<add

name="SqlProvider"

type="System.Web.Security.SqlRoleProvider"

connectionStringName="ExampleConnectionString"

applicationName="CReq3" />

</providers>

</roleManager>

 

<membership defaultProvider="SqlProvider">

<providers>

<add

name="SqlProvider"

type="System.Web.Security.SqlMembershipProvider"

connectionStringName="ExampleConnectionString"

applicationName="CReq3" />

</providers>

</membership>

 

 

 

</system.web>

 

</configuration>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...