Jump to content
Sign in to follow this  
Writeous

Verifying Username/Passwords

Recommended Posts

Writeous

Hello, I was wondering if anyone could help expand my novice knowledge. The start up GUI asks for username/pw input, then saves it to a .ini file (After if has gathered that information, it will no longer display this on startup). I was wondering if it is then possible to retrieve that information to check the Username and Password input box for verification on the log in screen. If the username/pw in the .ini file matchs what the user has typed into the username and password input box on the log in screen, then continue to the next screen, if not; exit. However, I can't seem to get it to work. I'm pretty sure that this statement is incorrect If $username NOT = GUICtrlRead($UserNameBox) AND $password NOT = GUICtrlRead($Passwordbox) , thanks for the help in advance.

Posted below is the full code. (I also used Koda, nice program)

CODE
#include <GUIConstants.au3>

Global $username, $password

Opt ("GUIOnEventMode", 1)

$ES_PASSWORD = 0x0020

; Read ini file for ID/PW if it's not there then need to fill in

$username = IniRead ("Login.ini", "Lockdown_ID", "LD_ID", "")

If $username = "" Then

$username = GUICtrlCreateInput ( $username, 100, 10, 96, 20 )

IniWrite ("Login.ini", "LD_ID", "ID", $username)

EndIf

; read ini file

$username = IniRead ("Login.ini", "Lockdown_ID", "LD_ID", "")

; check ini file

If $username = "" Then

$username = InputBox ("Create an account to proceed.", "Please enter your user name.")

IniWrite ("Login.ini", "Lockdown_ID", "LD_ID", $username)

EndIf

WinActivate ("Create an account to proceed.")

; user name creation

$username = GUICtrlCreateInput ($username, 100, 10, 96, 20)

$LD_ID = GUICtrlRead ($username)

; read ini file

$password = IniRead ("Login.ini", "account", "LD_PW", "")

; if pw = nothing, then fill in

If $password = "" Then

$password = InputBox ("Create a password to proceed.", "Please enter your password.", "", "*")

IniWrite ("Login.ini", "account", "LD_PW", $password)

EndIf

WinActivate ("Create a password to proceed.")

Func terminate()

exit 0

EndFunc

Func entervault()

If $username NOT = GUICtrlRead($UserNameBox) AND $password NOT = GUICtrlRead($Passwordbox) Then

$Form1_1 = GUICreate("Lockdown V.0.0.1", 541, 407, 243, 132)

GUISetBkColor(0x696969)

$TreeView1 = GUICtrlCreateTreeView(-8, 128, 385, 257)

$Button1 = GUICtrlCreateButton("Open", 384, 360, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Exit", 464, 360, 75, 25, 0)

$MenuItem1 = GUICtrlCreateMenu("&File")

$MenuItem4 = GUICtrlCreateMenuItem("Open", $MenuItem1)

$MenuItem5 = GUICtrlCreateMenuItem("Save", $MenuItem1)

$MenuItem6 = GUICtrlCreateMenuItem("Exit", $MenuItem1)

GUICtrlSetOnEvent ($MenuItem6, "terminate")

$MenuItem2 = GUICtrlCreateMenu("&Options")

$MenuItem9 = GUICtrlCreateMenuItem("Wipe Database", $MenuItem2)

$MenuItem3 = GUICtrlCreateMenu("&Help")

$MenuItem7 = GUICtrlCreateMenuItem("Contents", $MenuItem3)

$MenuItem8 = GUICtrlCreateMenuItem("About Us", $MenuItem3)

GUISetState(@SW_SHOW)

Else

Exit 0

EndIf

EndFunc

$Form2 = GUICreate("LockDown v0.0.1", 348, 302, 381, 195)

GUISetBkColor(0x696969)

$UserNameBox = GUICtrlCreateInput ("USER NAME HERE", 48, 216, 121, 21)

$Passwordbox = GUICtrlCreateInput("", 176, 216, 121, 21, $ES_PASSWORD)

$Enter = GUICtrlCreateButton("Enter", 96, 256, 75, 25, 0)

GUICtrlSetOnEvent ($Enter, "entervault")

$Exit = GUICtrlCreateButton("Exit", 176, 256, 75, 25, 0)

GUICtrlSetOnEvent ( $Exit, "terminate")

$Username = GUICtrlCreateLabel("Username", 48, 200, 52, 17)

$Password = GUICtrlCreateLabel("Password", 176, 200, 50, 17)

$Menu = GUICtrlCreateMenu("File")

$MenuItem1 = GUICtrlCreateMenuItem("Exit", $Menu)

$MenuItem5 = GUICtrlCreateMenu("Help")

$MenuItem2 = GUICtrlCreateMenuItem("Contents", $MenuItem5)

$MenuItem3 = GUICtrlCreateMenuItem("About Us", $MenuItem5)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd


[center][/center]

Share this post


Link to post
Share on other sites
enaiman

Why would you complicate your life without any reason?

Use If $username <> GUICtrlRead($UserNameBox) AND $password <> GUICtrlRead($Passwordbox)

And your statement is incorrect: "NOT =" is not the same thing as "<>"

If you like the NOT form: If $username = NOT GUICtrlRead($UserNameBox) AND $password = NOT GUICtrlRead($Passwordbox) -> you "negate" the variable not the operand.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Szhlopp

I've got a function called "Login()" you might be interested in. Check out my password manager (Link in sig). I use an INI file for encrypting/decrpyting as well as a pretty cool login GUI=)

Edited by Szhlopp

Share this post


Link to post
Share on other sites
enaiman

Guess you got the wrong quote Szhlopp ;)


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Szhlopp

Guess you got the wrong quote Szhlopp ;)

Doh :D

I may rewrite that function to work as a standard command. Wouldn't be to hard. Though I don't know really how many people would use it...

Share this post


Link to post
Share on other sites
Writeous

I've got a function called "Login()" you might be interested in. Check out my password manager (Link in sig). I use an INI file for encrypting/decrpyting as well as a pretty cool login GUI=)

That's a nice program you have made, but too advanced for me at the moment.

I've tried many, many different methods, all of which have resulted in failure. I've even tried:

If $username = IniRead ("Login.ini", "Lockdown_ID", "LD_ID", $username) <> GUICtrlRead($UserNameBox) AND $password = IniRead ("Login.ini", "account", "LD_PW",$password) <> GUICtrlRead($Passwordbox) Then

However, this only makes it so that the "Username" and "Password" input box can't be empty, as long as you have something entered in both of those input boxes it allows you to proceed to the main GUI.

I have the boot GUI make the user input a Username/Password, then it saves it to a .ini file. What I need the program to do is retrieve the .ini information during the login screen and verify that what the user entered into both the Username and Password input boxes is a valid UN/PW inside of the .ini file, if and only if it is valid that it allows the user to enter the main GUI.

Thanks for the quick responses, but my problem is still unresolved.

Posted below is the current code:

CODE
#include <GUIConstants.au3>

Global $username, $password

Opt ("GUIOnEventMode", 1)

$ES_PASSWORD = 0x0020

; Read ini file for ID/PW if it's not there then need to fill in

$username = IniRead ("Login.ini", "Lockdown_ID", "LD_ID", "")

If $username = "" Then

$username = GUICtrlCreateInput ( $username, 100, 10, 96, 20 )

IniWrite ("Login.ini", "LD_ID", "ID", $username)

EndIf

; read ini file

$username = IniRead ("Login.ini", "Lockdown_ID", "LD_ID", "")

; check ini file

If $username = "" Then

$username = InputBox ("Create an account to proceed.", "Please enter your user name.")

IniWrite ("Login.ini", "Lockdown_ID", "LD_ID", $username)

EndIf

WinActivate ("Create an account to proceed.")

; user name creation

$username = GUICtrlCreateInput ($username, 100, 10, 96, 20)

$LD_ID = GUICtrlRead ($username)

; read ini file

$password = IniRead ("Login.ini", "account", "LD_PW", "")

; if pw = nothing, then fill in

If $password = "" Then

$password = InputBox ("Create a password to proceed.", "Please enter your password.", "", "*")

IniWrite ("Login.ini", "account", "LD_PW", $password)

EndIf

WinActivate ("Create a password to proceed.")

Func terminate()

exit 0

EndFunc

Func entervault()

If $username = IniRead ("Login.ini", "Lockdown_ID", "LD_ID", $username) <> GUICtrlRead($UserNameBox) AND $password = IniRead ("Login.ini", "account", "LD_PW",$password) <> GUICtrlRead($Passwordbox) Then

$Form1_1 = GUICreate("Lockdown V.0.0.1", 541, 407, 243, 132)

GUISetBkColor(0x696969)

$TreeView1 = GUICtrlCreateTreeView(-8, 128, 385, 257)

$Button1 = GUICtrlCreateButton("Open", 384, 360, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Exit", 464, 360, 75, 25, 0)

$MenuItem1 = GUICtrlCreateMenu("&File")

$MenuItem4 = GUICtrlCreateMenuItem("Open", $MenuItem1)

$MenuItem5 = GUICtrlCreateMenuItem("Save", $MenuItem1)

$MenuItem6 = GUICtrlCreateMenuItem("Exit", $MenuItem1)

GUICtrlSetOnEvent ($MenuItem6, "terminate")

$MenuItem2 = GUICtrlCreateMenu("&Options")

$MenuItem9 = GUICtrlCreateMenuItem("Wipe Database", $MenuItem2)

$MenuItem3 = GUICtrlCreateMenu("&Help")

$MenuItem7 = GUICtrlCreateMenuItem("Contents", $MenuItem3)

$MenuItem8 = GUICtrlCreateMenuItem("About Us", $MenuItem3)

GUISetState(@SW_SHOW)

Else

Exit 0

EndIf

EndFunc

$Form2 = GUICreate("LockDown v0.0.1", 348, 302, 381, 195)

GUISetBkColor(0x696969)

$UserNameBox = GUICtrlCreateInput ("USER NAME HERE", 48, 216, 121, 21)

$Passwordbox = GUICtrlCreateInput("", 176, 216, 121, 21, $ES_PASSWORD)

$Enter = GUICtrlCreateButton("Enter", 96, 256, 75, 25, 0)

GUICtrlSetOnEvent ($Enter, "entervault")

$Exit = GUICtrlCreateButton("Exit", 176, 256, 75, 25, 0)

GUICtrlSetOnEvent ( $Exit, "terminate")

$Username = GUICtrlCreateLabel("Username", 48, 200, 52, 17)

$Password = GUICtrlCreateLabel("Password", 176, 200, 50, 17)

$Menu = GUICtrlCreateMenu("File")

$MenuItem1 = GUICtrlCreateMenuItem("Exit", $Menu)

$MenuItem5 = GUICtrlCreateMenu("Help")

$MenuItem2 = GUICtrlCreateMenuItem("Contents", $MenuItem5)

$MenuItem3 = GUICtrlCreateMenuItem("About Us", $MenuItem5)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd


[center][/center]

Share this post


Link to post
Share on other sites
Writeous

Anyone know?


[center][/center]

Share this post


Link to post
Share on other sites
james3mg

I've tried many, many different methods, all of which have resulted in failure. I've even tried:

If $username = IniRead ("Login.ini", "Lockdown_ID", "LD_ID", $username) <> GUICtrlRead($UserNameBox) AND $password = IniRead ("Login.ini", "account", "LD_PW",$password) <> GUICtrlRead($Passwordbox) Then

If I'm reading this right, it should be something like

If GUICtrlRead($UserNameBox) = IniRead("Login.ini", "Lockdown_ID", "LD_ID", "") AND GUICtrlRead($Passwordbox) = IniRead("Login.ini", "account", "LD_PW","") AND GUICtrlRead($UserNameBox) <> "" AND GUICtrlRead($PasswordBox) <> "" Then

Give that a try...

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites
Writeous

If I'm reading this right, it should be something like

If GUICtrlRead($UserNameBox) = IniRead("Login.ini", "Lockdown_ID", "LD_ID", "") AND GUICtrlRead($Passwordbox) = IniRead("Login.ini", "account", "LD_PW","") AND GUICtrlRead($UserNameBox) <> "" AND GUICtrlRead($PasswordBox) <> "" Then

Give that a try...

If GUICtrlRead($UserNameBox) = IniRead("Login.ini", "Lockdown_ID", "LD_ID", "") AND GUICtrlRead($Passwordbox) = IniRead("Login.ini", "account", "LD_PW","") AND GUICtrlRead($UserNameBox) <> "" AND GUICtrlRead($PasswordBox) <> "" Then

Thank you! That fixed the problem, I appreciate the help. ;)


[center][/center]

Share this post


Link to post
Share on other sites
james3mg

np


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×