Page 1 of 1 1
Topic Options
#44016 - 2003-08-13 04:20 PM Authentication and mapping via script
neilj Offline
Fresh Scripter

Registered: 2003-08-08
Posts: 13
With errorlevels can you determine that a prompt for a username/password is incorrect at that time? The mapped drive is in a remote network, and the prompt is via the script for username and password. at present you can type in rubbish and the drive is still there called "Network Drive", but obviously cannot connect. I would have thought that when you click on the drive it would prompt you, but it didn't. [Confused]

Thanks.

NJ

Top
#44017 - 2003-08-13 04:54 PM Re: Authentication and mapping via script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Hmmm. Not sure.

The following construct should work, just fill in the correct details. I'm assuming you get an "access denied" (error 5) due to incorrect credentials, but I can't test here so you may need to change it.
code:
$iAccessDenied=5		; Change to correct error message.
$iConnectAttempts=3 ; Number of times to attempt connection
$sSharePath="\\server\shares" ; Path to share
$sDriveToMap="X:"

Use $sDriveToMap /delete /persistent
Use $sDriveToMap $sSharePath
While @ERROR=$iAccessDenied AND $iConnectAttempts
$iConnectAttempts=$iConnectAttempts-1
"Enter login: " Gets $sLogin
"Enter Password: " Color "n/n" Gets $sPassword Color "w/n"
If Not $sLogin $sLogin=@USERID EndIF
Use $sDriveToMap $sSharePath /USER:$sLogin /PASSWORD:$sPassword
Loop

If @ERROR
"FATAL: Could not map "+$sSharePath+", last error="+@SERROR ?
EndIf

This scriptlet attempts to map the drive with current credentials, and if it fails due to access denied it will then prompt 2 or three times for login and password then use those. If it fails all attempts or if the connection fails for another reason it displays the last error.

Top
#44018 - 2003-08-13 06:20 PM Re: Authentication and mapping via script
drathgar Offline
Fresh Scripter

Registered: 2003-08-09
Posts: 13
I was just working with mapping drive, though I have nothing useful to add to this post. I was just wondering what the /persistent meant. Currently I am not using that argument.

Thanks
John

Top
#44019 - 2003-08-13 06:23 PM Re: Authentication and mapping via script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
quote:
I was just working with mapping drive, though I have nothing useful to add to this post
That would be considered hijacking a thread. It would be better to start a new thread e.g. in the 'General' forum. See ABC's of KiXtart board etiquette and message to new forum users

Persistent means that the share is being mapped persistently, e.g. the drive mapping will be reestablished during a login process without explicitly mapping the drive again.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 952 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.324 seconds in which 0.093 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org