Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Up Usernames and Passwords to VB Program 1

Status
Not open for further replies.

BitCounter

Programmer
Feb 18, 2000
28
0
0
US
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!
 
Well do you want to use Access as the database?<br>
If so you can have a separate table called users.<br>
Have the users name and a password field<br>
Also you can then open the database in Access to troubleshoot etc.<br>
Then create a Login dialog box(there is one that comes with VB6)<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Doug:<br>
<br>
Currently, I am using an ACCESS 97 database. I have created a table called passwords. It has 2 fields:<br>
Adminpassword<br>
Assistpassword<br>
<br>
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]. <br>
<br>
Should I instead change my password table structure to be something like this:<br>
<br>
UserName<br>
Password<br>
<br>
...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? <br>
<br>
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.<br>

 
Anxious -<br>
<br>
How about having a table containing the username and an access level.<br>
USERNAME ACCESSLEVEL<br>
---------- -----------<br>
Joe 1 <br>
Bob 2 <br>
BadUser 0 <br>
<br>
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.<br>
<br>
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.<br>
<br>
Chip H.<br>
<br>

 
Chip:<br>
<br>
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). <br>
<br>
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.
 
We had similiar situation and Login/password was very much required.<br>
<br>
Create a table with fields as NAME, PASSWORD and RIGHTS.<br>
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.<br>
<br>
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.<br>
<br>
I hope this will solve your problem. <p>Manoj Kalekar<br><a href=mailto:manoj_kalekar@yahoo.com>manoj_kalekar@yahoo.com</a><br><a href= > </a><br>
 
BitCounter -<br>
<br>
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.<br>
<br>
Chip H.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top