marko001 Posted June 10, 2011 Share Posted June 10, 2011 Hi all, I'm interested in creating a tool that can check credentials remotely to retrieve if login/password is on a "white list" so to grant access to the program. So mainly the user will insert username/password and press "Login" #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 213, 157, 192, 124) GUICtrlCreateLabel("Username", 16, 48, 52, 17) $username = GUICtrlCreateInput("", 72, 46, 121, 21) GUICtrlCreateLabel("Password", 16, 72, 50, 17) $password = GUICtrlCreateInput("", 72, 70, 121, 21) $login = GUICtrlCreateButton("Login", 14, 96, 179, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $login _checkCredentials($username,$password) EndSwitch WEnd Func _checkCredentials($username,$password) EndFunc The function _checkcredentials(...) should check a remote file john,qwerty peter,123456 William,1q2w3e ...,... and check if the credentials are in the file. If YES, continue program, if NOT, exit. I need a function similar to _readfile2Array from remote and check existence of the datas given by $username and $password. Can you help me with this? Thanks a lot, Marco Link to comment Share on other sites More sharing options...
water Posted June 10, 2011 Share Posted June 10, 2011 (edited) What do you mean by "remote"? It depends on the way you can connect to the remote system. Is it another computer/server on a company network? Is it on the internet? Do you have access to the remote machine so you can install a "server" component? ... Edited June 10, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
hannes08 Posted June 10, 2011 Share Posted June 10, 2011 Hi Marko001, If you are in a LAN environment and you have access to the appropriate share you can use _FileReadToArray(). But then again I would not save the passwords in cleartext. Have a look at the _Crypt___() Functions in the helpfile. If you are not in a LAN environment you'll need to write a client-server type of application. So lookup TCP___() Functions in the helpfile. In this case it is not less important that you use encryption. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
marko001 Posted June 10, 2011 Author Share Posted June 10, 2011 (edited) I did it this way, it works perfectly but I don't like downloading the full list. Is there a way to avoid it? expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <array.au3> $s_CredentialPath = "http://www.mysite.com/credentials" $s_CredentialSite = "Login_Pw_Session.txt" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 213, 157, 192, 124) GUICtrlCreateLabel("Username", 16, 48, 52, 17) $username = GUICtrlCreateInput("", 72, 46, 121, 21) GUICtrlCreateLabel("Password", 16, 72, 50, 17) $password = GUICtrlCreateInput("", 72, 70, 121, 21) $login = GUICtrlCreateButton("Login", 14, 96, 179, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $login $logtest = _checkCredentials(GUICtrlRead($username),GUICtrlRead($password),$s_CredentialPath,$s_CredentialSite) _testresult($logtest) EndSwitch WEnd Func _checkCredentials($username,$password,$path,$file) local $temp_file = @TempDir & "\sdfjsdflkjs.txt" local $hwnd = InetGet($path & "\" & $file, $temp_file) $countlines = _FileCountLines($temp_file) for $i = 1 to $countlines $line = FileReadLine($temp_file,$i) $string = StringSplit($line,",") if $username = $string[1] Then if $password = $string[2] Then Return 1 Else return 0 EndIf Else EndIf Next EndFunc Func _testresult($check) if $check = 1 Then msgbox(0,"OK", "Login OK") EndIf if $check = 0 Then msgbox(0,"NO!", "Failed") EndIf EndFunc And yes, avoiding password visibility should be a must Edited June 10, 2011 by marko001 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now