Click here to Skip to main content
13,295,051 members (67,899 online)
Rate this:
Please Sign up or sign in to vote.
Need help please Authentication please

I have these property username(String),password(string) ,name(String) and Role(Char) in my database(Authentication table)
i need a Authentication(login) per the Role. please give me some example links.
Posted 5-Feb-13 9:36am
Abhishek Pant 5-Feb-13 14:43pm
CShubham 6-Feb-13 1:27am
Hi!! Kindly find this article
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I was working on same task and made it by reading below blog[^]

Accept and vote if helps otherwise revert back with queries
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

try this

The below code should be in your Loging page.
Sub validateuser()
           sqlcon = New OleDbConnection(constr)
           sqlcmd = New OleDbCommand("SELECT COUNT(*) FROM att_userrole WHERE username = '" + Login1.UserName + " AND password = '" + Login1.Password + "'", sqlcon)
           retval = sqlcmd.ExecuteScalar
           If retval = 1 Then
               sqlcmd = New OleDbCommand("SELECT role, emailid FROM att_userrole WHERE username = '" + Login1.UserName + "'", sqlcon)
               sqlrdr = sqlcmd.ExecuteReader()
               Session("username") = Login1.UserName
               getrole = (sqlrdr.Item("role"))
               Session("userrole") = getrole
               getemail = (sqlrdr.Item("emailid"))
               Session("reqemailid") = getemail
               'Response.Write("you are valid " & Session("username") & " with role " & getrole)
               'IF USERNAME IS INVALID
               '-----YOUR CODE GOES HERE----
              lbl_msg.Text = ("Invalid login attmept")
           End If
       Catch ex As Exception
           lbl_msg.Text = ex.Message.ToString
       End Try
   End Sub

After authentication and checking you save the details in Sessions. Then in other pages just check the session values like the below
If Session("username") = "" Then
          loggedin = 0
          Master.ChangeLabel("Welcome " & Session("username") & " | " & Session("userrole") & " | ")
      End If
      If Session("userrole") = "Admin" Then
         'You are admin and put your code here
          'You are guest, put your code here
      End If
Marcus Kramer 6-Feb-13 13:56pm
My 1. Sql Injection nightmare.
joe_j 7-Feb-13 8:08am
didnt understand that comment!
faizyab 2009 9-Feb-13 2:22am
Thank you so much . this example will be very helpful for me .
joe_j 10-Feb-13 6:17am
You are welcome. If it helped, then it would be nice to vote this answer please

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171207.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100