Modify SSIS package’s ProtectionLevel and password using C#

Categories: Database; Tagged with: ; @ December 9th, 2012 13:24


Modify SSIS DTSx package production level and password.


It’s terrible to open and edit each package, luckily, we got the interface: Microsoft.SqlServer.Dts.Runtime. (How to add the lib)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

    class DtsUtils
         * Change DTSX package password
        public static void changePassword(String pkgLocation, String oldPassword, DTSProtectionLevel dtsPrdLevel, String newPassword)
            Application app = new Application();

            if (oldPassword != null && oldPassword.Trim() != "")
                app.PackagePassword = oldPassword;

            Package pkg = app.LoadPackage(pkgLocation, null);

            // Modify the password
            pkg.ProtectionLevel = dtsPrdLevel;
            pkg.PackagePassword = newPassword;

            // Save dts pacakge
            app.SaveToXml(pkgLocation, pkg, null);

Get source code from GitHub:

Besides password, there’re many interfaces, like logging, Connections, variables,.


1. SaveToXml:

2.  Building Packages Programmatically


// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.