Reputation: 1246
So I have a script task in an SSIS package that accesses email.
ExchangeService service = new Microsoft.Exchange.WebServices.Data.ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.Credentials = new NetworkCredential("[email protected]", "123");
I have encrypted the package itself, but am still feeling uneasy that it's in plain text on the ScriptMain.cs page. In the past I was able to encrypt this data on say WPF applications, but not sure how that can translate to a script task. Am I over thinking this? Is there a way to set this up in connection managers or something else that would add one more layer of protection?
I wanted to add I'm using the exchange services API to connect to the email.
Upvotes: 1
Views: 3349
Reputation: 527
According to EWS Managed API clients , 'Domain-joined clients that target an on-premises Exchange server can use the default credentials of the user who is logged on, assuming the credentials are associated with a mailbox'
So you may be able to use;
service.UseDefaultCredentials = true;
If that isn't possible, I'd recommend storing it in a database to be retrieved. You'll be able to secure/encrypt it in a Database.
Also, if you're using SQL 2012 or later, you could use a sensitive parameter. This is assuming you want to parameterize the password and/or username.
public void Main()
{
try
{
string value = Dts.Variables["$Package::ExchangePassword"].GetSensitiveValue().ToString();
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception e)
{
Dts.Log(e.Message, 0, null);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
Upvotes: 0
Reputation: 5246
You can use so called sensitive package or project parameters; environment params mapped to such params are stored in SSIS Catalog encrypted. Just create one for your password and get it in your Script task with .GetSensitiveValue()
method like
Dts.Variables["$Package::YourPassword"].GetSensitiveValue().ToString()
as described by Matt Masson.
Upvotes: 1