Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Setting Up Usernames and Passwords to VB Program

Setting Up Usernames and Passwords to VB Program

Setting Up Usernames and Passwords to VB Program

I am totally lost! I have an application that I need to be able to allow 2 different user-types to access. I want an Admin user who can access everything and I want another user who is limited to particular options from the main menu. What's the best way to accomplish this? I would also like to limit attempts to logging in at 3. I know that I can hardcode a password into my program...but ideally, it would reside in a table somewhere so that they can periodically change their password. Any help would be greatly appreciated!

RE: Setting Up Usernames and Passwords to VB Program

Well do you want to use Access as the database?
If so you can have a separate table called users.
Have the users name and a password field
Also you can then open the database in Access to troubleshoot etc.
Then create a Login dialog box(there is one that comes with VB6)


RE: Setting Up Usernames and Passwords to VB Program


Currently, I am using an ACCESS 97 database. I have created a table called passwords. It has 2 fields:

I am also using the login dialog box that comes with VB6. This one wants to automatically pull up the Windows User Name [by using GetUsernameA].

Should I instead change my password table structure to be something like this:


...and have 2 records one for each user (i.e., one for Admin with Admin as UserName, xxxx (something) for password and another one for Assist with Assist as UserName and some password?

I just can't get my code to work...I created a function called loginfailure, but it passes to loginfailure every time! Also I can't get loginfailure_Count to increment, so I'm not really limiting to 3 login attempts. I would like more information, specifically code snippets if at all possible.

RE: Setting Up Usernames and Passwords to VB Program

Anxious -

How about having a table containing the username and an access level.
---------- -----------
Joe 1
Bob 2
BadUser 0

If the username isn't in the table, they get lowest level of access (potentially, no access at all). Otherwise they get the level as specified in the row with their name.

To store/retrieve the name, use the GetUsernameA() function, so the users don't have to type it in every time. And you get the benefit of Windows providing your security -- if they're authenticated to Windows, they're OK.

Chip H.

RE: Setting Up Usernames and Passwords to VB Program


Where does the password fit in this scenario? Does it become irrelevant? The problem with this that I see is that say Joe goes to Bob's computer (which is already turned on because Bob is out to lunch), then Joe can easily start my program and get Bob's access simply because he's sitting at Bob's desk [where Bob is already logged into Windows at]. Yes, obviously the machines need password-protected screen savers...but this particular application would contain potentially damaging information in it should it be viewed by the wrong person. I want to require a password (it's okay to use GetUserNameA() to get the username, but apparently, it does not test the input password to see if it matches the Windows password).

Also do you have any tips on how to limit login attempts to three? I've got a counter variable set-up and it is supposed to increment everytime, but apparently each time the function is called, the variable is re-set to 1! Therefore, it can never each the max_login variable.

RE: Setting Up Usernames and Passwords to VB Program

We had similiar situation and Login/password was very much required.

Create a table with fields as NAME, PASSWORD and RIGHTS.
You can use cryptic functions to crypt the passwords. Assign special values to each menu items and provide this in the rights. When ever the username and password is verified read the rights and make the menu item enable or visible by creating functions. By providing rights multi-level of users is automatically designed.

For limiting the users to 3 only, you can use a table with one field as NOOFUSERS and update/ increment the count when ever the user logs in, Make sure that your MainForm unload/exit procedure decrement the count. In place of this table you can also create a flat file to be kept in SERVER.

I hope this will solve your problem.

Manoj Kalekar

RE: Setting Up Usernames and Passwords to VB Program

BitCounter -

If your app runs exclusively on Windows NT/2000 you could call the LogonUser() function. If you successfully receive an access token, you know the password they entered was good (it gets verified against the domain controller or a local cached copy). Be sure to call CloseHandle() afterwards to make sure things get cleaned up.

Chip H.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close