Set FTP password in SSIS

In: SQL Server|SSIS
Written by: Taylor Gerring


24 Nov 2008

Undoubtedly, you’re reading this because you’ve discovered that SQL Server Integration Services (as of SSIS 2008) will not allow you to set the password of an FTP connection through expressions. Fortunately, there is an easy workaround, that requires a simple Script Task. While not as simple as native expression support, it’s darn close. I’ve included C# code, but you may need to adapt to VB.Net if that’s your preferred flavor.

  1. Ensure a string variable is setup with the password. For this demo, I’m using the name, “FTPPassword”
  2. Add a Script Task to your package
  3. Edit the task
  4. On the Script page, click the elipsis for ReadOnlyVariables and check the box for User::FTPPassword.
  5. Click the “Edit Script…” button
  6. Change your entry point (Main, by default) to look like the below code. Save, close, and hit OK.
1
2
3
4
5
6
7
8
public void Main()
{
	ConnectionManager FTPConn;
	FTPConn = Dts.Connections["FTPServer"];
	FTPConn.Properties["ServerPassword"].SetValue(FTPConn, Dts.Variables["FTPPassword"].Value);
 
	Dts.TaskResult = (int)ScriptResults.Success;
}

A couple notes:

  • Ensure you update lines 4-5 to reflect the actual connection name. My example uses the name FTPServer.
  • Just to reiterate, my password is stored in the variable name FTPPassword. If yours is different make this change on line 5.

That’s it. Make sure you’ve got this task being executed before your actual FTP task and everything should work fine. Cheers!

Comment Form

@TaylorGerring


Unless specified otherwise, this website is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.
Stop SOPA
Unless specified otherwise, this website is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.