Code Comments
Programming Forum and web based access to our favorite programming groups.Environment: I am writing a HTA application front end to our server build au tomation. I am doing all of the testing in a lab that has a two machines, a PXE client system and a 2003 Server (DC01) that acts as a AD (2003 Native) DC, DHCP, DNS and RIS. The client PXE boots against this environment and runs WinPE based off of Window s 2003. Problem: In my application I attempt to map a drive to a user supplied resou rce (the code for this is below, but it's fairly cookie cutter). What I hav e discovered in my testing is that the function fails gracefully if either t he server is completely non -existant or is any system other then DC01. Any attempt to connect to DC01 with either invalid user credentials or an incorrect UNC (e.g. invalid share ) will result in the application hanging indefinately. This only occurs aga inst DC01, but I also have a limited test environment to validate this. The function hangs while execu ting MapNetworkDrive. On the DC01 server, the security event log fills up w ith hundreds of successful logons per second until I either kill the MSHTA.e xe shell OR I attempt to ac cess the strFreeDrive value from a command prompt. Attempting to access the drive letter the function is hung on mapping will come back with a "The sys tem cannot find the path specified." error in the command prompt, at which p oint the MapDrive function will return error 53 "The network path was not found". The function works a s expected if you do not typo or otherwise munge the UNC, and it always work s against a different file server (or immediately errors if the UNC is incor rect). I'm hoping, but doubting, this is something I can code around? Code: function MapDrive(strFreeDrive, objNetwork, strUNC, strCredUser, strCredPass ) ' Maps a drive with the supplied credentials to a UNC path ' strFreeDrive is the drive letter to map ' objNetwork is the Network Object ' strUNC is the UNC path to map the drive to ' strCredUser is the user credential ' strCredPass is the credential password ' Returns the mapped drive letter on success and blank/empty on failure dim blnMappedDrive blnMappedDrive = true On Error Resume Next objNetwork.MapNetworkDrive strFreeDrive, strUNC, false, strCredUser, strCred Pass If err.number <> 0 then Msgbox "Error Connecting to: """ & strUNC & """" & vbcr & err.description & vbcr & "Please try again.", vbokonly, "Info" On Error GoTo 0 blnMappedDrive = False End if On Error GoTo 0 if blnMappedDrive = True then MapDrive = strFreeDrive else MapDrive = Empty end if end function
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.