How to create a sort of login?

Hello

I want to make a program for certain people and I want it so that they need to enter a code the first time they run the program. The codes would need to be programmed into the program and a certain code would need to show certain info in the program ( for example: if someone entered code 12345 on the first startup the program would show 'welcome name'). If you need some extra explenation just ask.

I would like to know how to do this.

Bye and thanks in advance.



Answer this question

How to create a sort of login?

  • Paul B - Miami

    Renee,

    Thanks for the response. I've seen examples for storing the salted hash of a password in a db and ultimately, that's the route I'd like to take. For now though, I'd just like to start with a basic query utilizing my "UsersTableAdapter" to handle the comparison, get that working, then strengthen the security of the passwords from there...I'm just not sure how to configure the query for the comparison.



  • Handofphate

    I pretty much agree with Spotty. I start my main form invisible... and instantiate the login form. It's connected to database containing passwords and usernames and does user validation and evasion is necessary.

    My form just passed back "logged in" or "wasn't logged in".



  • Mukool

    Renee,

    Thanks very much for taking the time and posting your solution! It definitely gives me some ideas...



  • Nitin Chintamani

    Thats the general idea - my solution was very very crude and simple with simple comparison of strings but if you want to go more advanced then sure, you can create a database and pass them across to the database to validate the user identity there.


  • wavemill

    K, I'm going to try it out tommorow.


  • ravivarma

    Tabdalla,

    I'm sorry but in my programming I don't use SQL commands.

    I could tell you how to do it in VB2005 but not with SQL.



  • Edwar Smeathers

    Thinking.... I've done this in VB6....

    Let me see if I can find a table...brb



  • mike bel

     

    Well what do you know

    SysUsers
    ID UserName Password Privileges FullName Last Login date PwdChng
    1 renee ****** Yes Renee 1/20/2003 5:49:27 PM Yes
    2 kathleen ****** Yes Kathleen
    No
    3 Kelly ***** No Kelly
    No
    13 Gloria ****** No Gloria Steinem 1/19/2003 8:03:01 PM No

    written from memory..... We have collected the username and passwword

    dim Table as Datable = adodb.gettable("SysUsers") 'Member variable
    dim PrivilegedUser as boolean
    dim LoggedOn as Boolean

     

    if not ValidateUser(Username,Password) then end

         'Process code here

    End Sub

    Private Function ValidateUser(Byval UserName as String, Byval Password String) as boolean

      For each row as DataRow in Table.Rows

        if ((UserName = row("UserName") and (Password = row("Password"))) then  
           If Row(  "Privileges") then PrivilegedUser = true Else PrivilegedUser = false
           LoggedOn = true
           return true
        End IF

    Next

    Return False

    End Function

     

    Hows that

    This is a gross simplification because I also had "Evasion" as part of the login scheme. If a user failed to log in three time within a rolling interval, the application hid for about 5 minutes as a security enhancement.

     



  • captJackSparo

    You have a login form dialog as a template form type.

    So add one to you project.

    You need to instantiate an instance of this login form and show it from you main form. When you click OK you will use the username and password textbox text properties and determine if the code was correct by simple comparison operators.

    If it is good - then set a property (or a variable in a module ) which determines the user name you have validated and this can then be retrieved from the original calling form.


  • albator69

    Renee,

    I'd appreciate seeing how you would do it. If there's one thing I've learned doing this is there's always more than one (sometimes 4-5) way of doing things...



  • Paintshow

    Spotty,

    Can you elaborate a little more on the comparison strings That's really the last part I have to complete in my app. I have custom IIdentity and IPrincipal objects that handle the authentication from the user input on the login form. Right now just to get things working, I hardcoded the username and password. I want to convert things to where the code compares the user input on the login form with what's stored in a "Users" table in a SQL 2005 database that contains the columns "UserID" (primary key), "Username", "Password", and "Role." I use the return vale of the role to either enable or disable controls on my forms.

    If you could help me out with a code example on how to do the username and password comparison, I would really appreciate it!

    Thanks in advance for any help,

    Tony

    P.S. Sorry to hijack the post, but I'm getting a little desparate to get this working!



  • L Zhou

    They key concern is protection of the passwords. It is only the poorest of system that save strings.

    The better ones I've seen do this... Let's say there was a password "Squibbish"

    when first entered, 16 bit seed is collected and stored

    Together Squbbish and the seed are processed in TransformX and turned into SomethingElse and SomethingElse is also stored.

    When someone then enters a password, the seed and SomethingElse are located by the username. The seed and password are again processed and it's product is compared to somethingelse.

    If they match you have a logon.



  • How to create a sort of login?