forms authentication

Results 1 to 3 of 3

Thread: forms authentication

  1. #1
    Join Date
    Dec 1969

    Default forms authentication

    Has anyone done forms authentication by checking the database for the userid and password?<BR>if yes, can u help me out with either the code or hint?<BR>thx

  2. #2
    Join Date
    Dec 1969

    Default RE: forms authentication

    &#060;Script language="vb" runat="server"&#062;<BR>Sub DoLogin(objSender as Object, objArgs as EventArgs)<BR> dim userid = txtUser.Text<BR> dim password = txtPwd.Text<BR> dim isAuthenticated as Boolean = False<BR> dim rememberLogin as Boolean = chkRemember.checked<BR> <BR> Dim dbcon As New SqlConnection(ConfigurationSettings.AppSettings("D SN")) &#039; i stored dsn in web.config<BR><BR> Dim cmd as SqlCommand = new SqlCommand("sp_Login_Authenticate &#039;" & userid & "&#039;", dbcon) &#039;i have a stored procedure which basically does "select userid, password, and_other_stuff from [user] where userid = the_value_you_entered&#039;<BR><BR><BR> dim dr as SqlDataReader = cmd.ExecuteReader()<BR> do while<BR> userid = dr("userid")<BR> Session("Name") = dr("Name") &#039;i grab user info for using while he is on the site<BR> Session("email") = dr("Email")<BR> if password = dr("password") then isAuthenticated = True<BR> loop<BR> <BR> If isAuthenticated Then<BR> FormsAuthentication.RedirectFromLoginPage(userid, rememberLogin)<BR> else<BR> msgStatus.InnerHTML = userid & " failed authentication"<BR> end if<BR>End Sub<BR>&#060;/Script&#062;<BR><BR>My web.config includes:<BR> &#060;appSettings&#062;<BR> &#060;add key="DSN" value="server=localhost;uid=anton;pwd=blahblah;dat abase=myblahDb" /&#062;<BR> &#060;/appSettings&#062;<BR><BR>Enjoy

  3. #3
    Join Date
    Dec 1969

    Default Check out this article...

    Using Forms Authentication in ASP.NET<BR><BR><BR>Happy Programming!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts