March 9, 2009 at 8:32 am
Hi
I'm using SQLServer 2005 and create a SSIS-package with BIDS.
In that package I have a script task to access a Windows server network share.
Since this network share requires windows authentication I need a method to provide
username and password programatically to connect to the share.
Can anyone please add some sample VB.Net code that demonstrates how to achieve this.
Appreciate any thoughts
Thanks
Bodo
March 9, 2009 at 8:37 am
Can't you just grant the necessary folder permissions to the SQL Agent user and use a UNC path to access the files?
Phil
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
March 9, 2009 at 8:54 am
Thanks Phil,
unfortunately the network admins grant access only for a single specific windows-account
that I must specifiy when accessing the share.
Bodo
March 9, 2009 at 4:46 pm
You'll need to impersonate the other user account and then access the share as normal.
This will require a call to the LogonUser win32 api function (lives in advapi32.dll). This function allows you to pass in a username, password and domain.
Log on as the other user, do what you need, then undo the impersonation.
Just Google a few keywords and you should get some useful info. Note that I've never tried this from a Script Task in SSIS... though I can't think of a reason that it wouldn't work.
March 10, 2009 at 4:29 am
Thanks for your post,
I found this article very helpfull and use the code in my SSIS Script task:
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply