Jump to content

(SOLVED): Network Login Script (UNSOLVED): Debugging


Recommended Posts

  • 2 weeks later...

Ok,

So the script that I set out to make has been created successfully. My only problem at the moment is some debugging issues.

I find that often my new script has an error that is quite odd.

Here is my finished product:

Local $user = InputBox("B:", "Enter your username", "", "", 215,137)
If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf

If $user <> "tony" and $user <> "clare" and $user <> "ric" Then
Msgbox(0, "Failure", "The username is not recognised")
Exit
EndIf

Local $passwd = InputBox("Attempting to Access B:", $user & ", please enter your password", "", "*",215,137)
If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf
DriveMapDel("B:")
DriveMapAdd("B:", '\\NAS-EA-B6-EF\Beaches', 0, "domain\" & $user, $passwd)
If @error = 1 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error Code: " & @extended & @CRLF & "Please contact your IT Support")
   Exit
ElseIf @error = 2 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied")
   Exit
ElseIf @error = 3 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned")
   Exit
ElseIf @error = 4 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name")
   Exit
ElseIf @error = 5 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share")
   Exit
ElseIf @error = 6 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password" & @CRLF & "If you have forgotten your password please contact IT Support")
   Exit
EndIf
MsgBox(1, "B:", "You have been logged into B:")
#cs
ShellExecute("C:\Network Authentication\login.bat", $passwd) <-- OLD CODE FOR BATCH EXECUTION - ONLY USE IF DriveMapAdd DOESN'T WORK
#ce

I find that often my error message for @error = 1 is showing up. The @extended value is one that corresponds to a windows error. I do not know why sometimes the error is thrown and other times it isn't.

That WinAPI error that I get returned is for an error regarding multiple logins to the share using the same or different credentials. It should not matter. I have the NAS (Which is what I am logging into at \\NAS-EA-B6-EF ) Fully set up with three accounts named ric, clare and tony. Each account has access to Beaches which is usually a read/write protected share.

I connect in the only way that windows can and sometimes it wont let me log in, other times it will.

If I get the multiple connections error, then I have to navigate through my network in explorer, into the NAS and then into Beaches. Windows prompts for user/pass automatically and I can get in fine. It is just mapping the drives that is a problem.

Anyone that can shed some light here would be a life saver cheers

Link to comment
Share on other sites

  • 2 weeks later...

Just a style issue...

I'd offered an example back on page 1 of this thread that demonstrated differing methods one might use to display error messages to your user. One being a fancy tooltip, the other a msgbox. You would likely wish to decide which appearance/behavior you prefer and use that method consistantly, rather than hang onto the "@error =1 --> Tooltip(), @error=2 --> Msgbox()" example.

Link to comment
Share on other sites

  • 8 years later...

As an aside, just wondering when I invoke Task Manager in Windows using the three finger salute and examine the command line, will the password you passed be there for all to see, including other tasks and programs on the system, in plain text?

Security should advisedly be done at the OS level, not the user program level. Map your drive after the user has authenticated at the OS level using OS security, and the OS has granted them the correct permission, and then test if they have access. This way you won't have to store passwords and user names inside your code and have all the complications if tony leaves, ric dies, and you have a temporary intern for the summer, needing to recompile your code and re-deploy it to all the places it is needed.

Will "IT support" be able to modify the code as needed, adding and removing users and passwords? Will the code be readable, or just executable without being able to be read, with the embedded security attributes?

I know, it is just a quick, simple and dirty kludge, just to get you by for just three users, but it is at the forefront of your entire login session, leaving you wide open for nefarious activities that you will not have a lot of control over if something goes nastyware.

 

PS: Clear that password variable as soon as you can after you have used it.

Edited by Confuzzled
Link to comment
Share on other sites

You did notice that the thread has been inactive for > 8 years and the OP has been offline since?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Developers
7 hours ago, Tcarey8080 said:

WorD2%

Whatsup with these crazy replies?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers
1 minute ago, Confuzzled said:

The issues are even more relevant today.

Just stay out for now please...  should be sort of obvious ...and do not reply to this one.

@Tcarey8080, I expect the next post to be yours! 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

×
×
  • Create New...