Sql activex job keeps failing - mapping network drive

  • I have a sql agent job setup that runs a simple activex (vbscript) script to map a drive to our AS400.  When I run the scheduled job, the job is successful, however it maps the drive as Z:\Disconnected Network Drive.  I can access the share, but I can't disconnect the mapped drive in a later step.

    The frustrating part is that if I create a DTS package with the same script and run it from inside DTS designer it works just fine.  Also, if I create a .vbs file and run it from Windows Explorer it will work ok.

    What is causing the problem when it is run as a job step?

    Option Explicit

    Function Main()

    Dim WshNetwork, oDrives

    Set WshNetwork = CreateObject("WScript.Network")

    WshNetwork.MapNetworkDrive "z:","\\as400\share\",false,"user","password"

    Set WshNetwork = nothing

    Main = true

    End Function

  • It sounds like account issue, what type service account do you use to run SQL Server Agent and what permissions does it have to the share drive in AS400?

  • SQL Server Agent is running as a domain user with elevated rights on the box (local admin).  It does not have any rights to the share on the AS400 because the AS400 will not authenticate a windows user.  When I attempt to map the drive, I pass in the as400 userid and password to make the connection. 

    I am confused as to why the same script works from inside the DTS designer or as a .vbs file.

  • When you run that script from a Job it is using SQL Server Agent service credentials. Services do not know anything about mapped drives because that information is kept in the user profile which services don't have. When you run it from DTS and vbs is using your user credentials and your user account does have a user profile associated   

    Use direct access with unc path instead!

    hth

     


    * Noel

  • Noeld,  Thanks, your post makes sense to me, I will give it a try.

  • Noeld, when you use direct access, is there a way to use a specified userid and password.  That was why I was trying to map the drive.  The as400 will require as400 security authentication, not windows.

    Thanks

  • No Problem, Feel free to post again if you find any more problems


    * Noel

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply