SSIS: Accessing a network drive using a different username and password

后端 未结 5 602
借酒劲吻你
借酒劲吻你 2020-12-14 13:17

Is there a way to connect to a network drive that requires a different username/password than the username/password of the user running the package?

I need to copy f

5条回答
  •  轮回少年
    2020-12-14 13:39

    You can use the Execute Process task with the "net use" command to create the mapped drive. Here's how the properties of the task should be set:

    Executable: net

    Arguments: use \Server\SomeShare YourPassword /user:Domain\YourUser

    Any File System tasks following the Execute Process will be able to access the files.

    Alternative Method

    This Sql Server Select Article covers the steps in details but the basics are:

    1) Create a "Execute Process Task" to map the network drive (this maps to the z:)

    Executable: cmd.exe
    Arguments: /c "NET USE Z: "\\servername\shareddrivename" /user:mydomain\myusername mypassword"
    

    2) Then run a "File System Task" to perform the copy. Remember that the destination "Flat File Connection" must have "DelayValidation" set to True as z:\suchandsuch.csv won't exist at design time.

    3) Finally, unmap the drive when you're done with another "Execute Process Task"

    Executable: cmd.exe
    Arguments: /c "NET USE Z: /delete"
    

提交回复
热议问题