Accessing Sensitive Information in SSIS

Khidir Elsanosi 21 Reputation points
2020-10-29T16:02:12.257+00:00

I have username and password as package parameters [$Package::user] and [$Package::Pass], which I set the sensitivity property to true (Sensitive=True). These parameters are then used inside a script task (C#) to authenticate a rest call using httpClient as below:

            string myuser = Dts.Variables["$Package::user"].GetSensitiveValue().ToString();
            string mypass = Dts.Variables["$Package::pass"].GetSensitiveValue().ToString();

            var httpClientHandler = new HttpClientHandler()
            {
                Credentials = new NetworkCredential(myuser, mypass),
            };

            var client = new HttpClient(httpClientHandler);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var response = client.GetStringAsync(new Uri(url)).Result;

this peace of code returns the following error:
"Accessing value of the parameter variable for the sensitive parameter "pass" is not allowed. Verify that the variable is used properly and that it protects the sensitive information"

It worth mentioning that when I change the sensitivity of the parameters to (False) the exact same code above works, and I get the response back.

My question is: how to resolve this error, so I can make the rest call using the sensitive username and password.

Thanks

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,587 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yitzhak Khabinsky 25,956 Reputation points
    2020-10-29T16:20:47.577+00:00
    0 comments No comments

  2. Monalv-MSFT 5,901 Reputation points
    2020-10-30T03:04:37.1+00:00

    Hi @Khidir Elsanosi ,

    According to my test, we can use the following script to read the sensitive parameter :

    public void Main()  
    	   {  
                string myuser = Dts.Variables["$Package::User"].GetSensitiveValue().ToString();  
                string mypass = Dts.Variables["$Package::Pass"].GetSensitiveValue().ToString();  
                MessageBox.Show("MyUser: "+myuser+ "/n"+"MyPass: "+mypass);  
                Dts.TaskResult = (int)ScriptResults.Success;  
    		}  
    

    Please refer to the following links and pictures:

    Reading sensitive parameters in a script

    Access Control for Sensitive Data in Packages

    36075-sensitiveparameter.png

    36097-scripttaskreadonlyvariables.png

    36089-result.png

    Best Regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Hot issues in October--Users always get connection timeout problem when using multi subnet AG via listener. Especially after failover to another subnet.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.