예제 #1
0
        /// <summary>
        /// Edits the value of a parameter
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="value"></param>
        virtual public void EditItem(String parameter, object value)
        {
            AppAssert.AssertNotNull(parameter, "parameter");
            AppAssert.Assert(this.parameterList.Contains(parameter), "Parameter List does not contain this parameter", parameter);
            AppAssert.AssertNotNull(value, "value");

            InputParameter inputParameter = PropertyBagDictionary.Instance.GetProperty <InputParameter>(parameter);

            inputParameter.SetInputValue(value);
        }
예제 #2
0
        /// <summary>
        /// Logs all inputs to the log file
        /// </summary>
        public void LogInputs()
        {
            InputParameter inputParameter = null;

            foreach (String parameter in parameterList)
            {
                inputParameter = this.FindItem(parameter);
                if (inputParameter.Valid && inputParameter.CanLogToFile)
                {
                    SetupLogger.LogInfo(parameter);
                    SetupLogger.LogInfo(inputParameter.InputValue.ToString());
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Loads input values from a file
        /// </summary>
        /// <param name="file"></param>
        /// <param name="parameterList"></param>
        public void LoadFrom(String file, StringCollection parameterList)
        {
            AppAssert.AssertNotNull(file, "file");
            AppAssert.AssertNotNull(parameterList, "parameterList");

            this.LoadParameterList(parameterList);

            InputParameter inputParameter = null;

            foreach (String parameter in parameterList)
            {
                inputParameter = this.FindItem(parameter);
                inputParameter.LoadInputValue(file);
            }
        }
예제 #4
0
        public static string ConfigureServerCommandLineArguments()
        {
            StringBuilder arguments = new StringBuilder();

            // Check to see if this is an uninstall
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                arguments.Append("REMOVE=ALL ");
                arguments.AppendFormat(CultureInfo.InvariantCulture, "UNINSTALLSERVER = 1 ");
            }
            else
            {
                String serviceAccount = UserAccountHelper.GetServiceAccount();
                arguments.AppendFormat(CultureInfo.InvariantCulture, "SERVERACCOUNTNAME=\"{0}\" ", serviceAccount);  // for agent installation
                if (SetupInputs.Instance.FindItem(SetupInputTags.CmpServiceLocalAccountTag))
                {
                    serviceAccount = SetupConstants.LocalSystem;
                }
                arguments.AppendFormat(CultureInfo.InvariantCulture, "SERVICEACCOUNT=\"{0}\" ", serviceAccount); // for registry
                arguments.AppendFormat(CultureInfo.InvariantCulture, "USERNAME=\"{0}\" ", (String)SetupInputs.Instance.FindItem(SetupInputTags.UserNameTag));

                arguments.AppendFormat(CultureInfo.InvariantCulture, "SQLPORT=\"{0}\" ", (int)SetupInputs.Instance.FindItem(SetupInputTags.SqlServerPortTag));
                string sqlInstanceName = InstallItemCustomDelegates.GetSQLServerInstanceNameStr(false);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "INSTANCENAME=\"{0}\" ", sqlInstanceName);

                String dbName = (String)SetupInputs.Instance.FindItem(SetupInputTags.SqlDatabaseNameTag);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "DATABASENAME=\"{0}\" ", dbName);
                string partialConnectionString = SetupDatabaseHelper.ConstructConnectionString(sqlInstanceName);
                string connectionString        = String.Format("{0}database={1}", partialConnectionString, dbName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CONNECTIONSTR=\"{0}\" ", connectionString);

                string sqlMachineName  = DnsHelper.GetComputerNameFromFqdnOrNetBios((String)SetupInputs.Instance.FindItem(SetupInputTags.GetSqlMachineNameTag(false)));
                bool   onRemoteMachine = String.Compare(sqlMachineName, Environment.MachineName, true) != 0;
                arguments.AppendFormat(CultureInfo.InvariantCulture, "ONREMOTESERVER=\"{0}\" ", onRemoteMachine ? 1 : 0);

                String sqlMachineFqdn = DnsHelper.GetFullyQualifiedName(sqlMachineName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "SQLMACHINENAME=\"{0}\" ", sqlMachineName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "SQLMACHINEFQDN=\"{0}\" ", sqlMachineFqdn);

                arguments.AppendFormat(CultureInfo.InvariantCulture, "SETUPLANGUAGE=\"{0}\" ", CultureInfo.CurrentUICulture.Name);

                String certificateThumbprint = (String)SetupInputs.Instance.FindItem(SetupInputTags.CmpCertificateThumbprintTag);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CERTIFICATETHUMBPRINT=\"{0}\" ", "LocalMachine,My," + certificateThumbprint);

                // Encrypt the password of the worker service so that WAP extensions can use it
                InputParameter pwd            = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminPasswordTag);
                string         passwordAsText = null;
                if (pwd != null)
                {
                    IntPtr unmanagedString = IntPtr.Zero;
                    try
                    {
                        unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(pwd);
                        passwordAsText  = Marshal.PtrToStringUni(unmanagedString);
                    }
                    finally
                    {
                        Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
                    }
                }
                string encryptedPassword = String.Format("{0}{1}{2}", "[KText]", UserAccountHelper.EncryptStringUsingLocalCertificate(passwordAsText, certificateThumbprint), "[KText]");

                arguments.AppendFormat(CultureInfo.InvariantCulture, "CMPCONTEXTPASSWORDSTRING=\"{0}\" ", encryptedPassword);
            }

            return(arguments.ToString());
        }
예제 #5
0
        public static string ConfigureWAPExtensionCommonCommandLineArguments()
        {
            StringBuilder arguments = new StringBuilder();

            // Check to see if this is an uninstall
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                arguments.Append("REMOVE=ALL ");
            }
            else
            {
                arguments.Append("ADDLOCAL=ProductFeature,ServiceFeature ");

                // Save the user name to use on the cmp service database
                String userName = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminNameTag);

                // Add the SQL database information so that it can be written to the registry and accessed by the services
                arguments.AppendFormat(CultureInfo.InvariantCulture, "SQLPORT=\"{0}\" ", (int)SetupInputs.Instance.FindItem(SetupInputTags.SqlServerPortTag));
                string sqlInstanceName = InstallItemCustomDelegates.GetSQLServerInstanceNameStr(false);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "INSTANCENAME=\"{0}\" ", sqlInstanceName);

                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPSQLPORT=\"{0}\" ", (int)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlServerPortTag));
                string wapSqlInstanceName = InstallItemCustomDelegates.GetSQLServerInstanceNameStr(true);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPINSTANCENAME=\"{0}\" ", wapSqlInstanceName);

                String dbName = (String)SetupInputs.Instance.FindItem(SetupInputTags.SqlDatabaseNameTag);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "DATABASENAME=\"{0}\" ", dbName);
                string partialConnectionString = SetupDatabaseHelper.ConstructWebsiteConnectionString(SetupDatabaseHelper.SqlUsernameDuringInstall, sqlInstanceName);
                string connectionString        = String.Format("{0}database={1}", partialConnectionString, dbName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CMPCONNECTIONSTR=\"{0}\" ", connectionString);

                String wapDbName = (String)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDatabaseNameTag);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPDATABASENAME=\"{0}\" ", wapDbName);
                string wapPartialConnectionString = SetupDatabaseHelper.ConstructWebsiteConnectionString(SetupDatabaseHelper.SqlUsernameDuringInstall, wapSqlInstanceName);
                string wapConnectionString        = String.Format("{0}database={1}", wapPartialConnectionString, wapDbName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPCONNECTIONSTR=\"{0}\" ", wapConnectionString);

                string sqlMachineName  = DnsHelper.GetComputerNameFromFqdnOrNetBios((String)SetupInputs.Instance.FindItem(SetupInputTags.GetSqlMachineNameTag(false)));
                bool   onRemoteMachine = String.Compare(sqlMachineName, Environment.MachineName, StringComparison.OrdinalIgnoreCase) != 0;
                arguments.AppendFormat(CultureInfo.InvariantCulture, "ONREMOTESERVER=\"{0}\" ", onRemoteMachine ? 1 : 0);

                string wapSqlMachineName  = DnsHelper.GetComputerNameFromFqdnOrNetBios((String)SetupInputs.Instance.FindItem(SetupInputTags.GetSqlMachineNameTag(true)));
                bool   wapOnRemoteMachine = String.Compare(wapSqlMachineName, Environment.MachineName, StringComparison.OrdinalIgnoreCase) != 0;
                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPONREMOTESERVER=\"{0}\" ", wapOnRemoteMachine ? 1 : 0);

                String sqlMachineFqdn = DnsHelper.GetFullyQualifiedName(sqlMachineName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "SQLMACHINENAME=\"{0}\" ", sqlMachineName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "SQLMACHINEFQDN=\"{0}\" ", sqlMachineFqdn);

                String wapSqlMachineFqdn = DnsHelper.GetFullyQualifiedName(sqlMachineName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPSQLMACHINENAME=\"{0}\" ", wapSqlMachineName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPSQLMACHINEFQDN=\"{0}\" ", wapSqlMachineFqdn);

                String certificateThumbprint = (String)SetupInputs.Instance.FindItem(SetupInputTags.CmpCertificateThumbprintTag);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CERTIFICATETHUMBPRINT=\"{0}\" ", "LocalMachine,My," + certificateThumbprint);

                // Write the cmp database connection string
                sqlInstanceName            = InstallItemCustomDelegates.GetSQLServerInstanceNameStr(false);
                wapDbName                  = (String)SetupInputs.Instance.FindItem(SetupInputTags.SqlDatabaseNameTag);
                wapPartialConnectionString = SetupDatabaseHelper.ConstructWebsiteConnectionString(SetupDatabaseHelper.SqlUsernameDuringInstall, sqlInstanceName);
                wapConnectionString        = String.Format("{0}database={1}", wapPartialConnectionString, wapDbName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CMPCONNECTIONSTR=\"{0}\" ", wapConnectionString);

                String domain       = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminDomainTag);
                string fullUserName = String.IsNullOrEmpty(domain) ? userName : domain + @"\" + userName;
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CMPDATABASEUSERNAME=\"{0}\" ", fullUserName);

                // Encrypt the password of the worker service so that WAP extensions can use it
                InputParameter pwd            = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminPasswordTag);
                string         passwordAsText = null;
                if (pwd != null)
                {
                    IntPtr unmanagedString = IntPtr.Zero;
                    try
                    {
                        unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(pwd);
                        passwordAsText  = Marshal.PtrToStringUni(unmanagedString);
                    }
                    finally
                    {
                        Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
                    }
                }
                string encryptedPassword = String.Format("{0}{1}{2}", "[KText]", UserAccountHelper.EncryptStringUsingLocalCertificate(passwordAsText, certificateThumbprint), "[KText]");

                arguments.AppendFormat(CultureInfo.InvariantCulture, "CMPCONTEXTPASSWORDSTRING=\"{0}\" ", encryptedPassword);

                //Write the MicrosoftMgmtSvcStoreContext connection string (part of WAP original installation)
                wapDbName = SetupConstants.DefaultWapStoreDBName;
                wapPartialConnectionString = SetupDatabaseHelper.ConstructWebsiteConnectionString(SetupDatabaseHelper.SqlUsernameDuringInstall, sqlInstanceName);
                wapConnectionString        = String.Format("{0}database={1}", wapPartialConnectionString, wapDbName);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "WAPSTORECONNECTIONSTR=\"{0}\" ", wapConnectionString);

                X509Krypto krypto = new X509Krypto("My", "LocalMachine", certificateThumbprint);
                // Encrypt the password of the sql user that will be used by the website to access CMP DB
                //string encryptedCmpDbPassword = String.Format("{0}{1}{2}", "[KText]", UserAccountHelper.EncryptStringUsingLocalCertificate(SetupDatabaseHelper.SqlDbUserPassword, certificateThumbprint), "[KText]");

                string encryptedCmpDbPassword = krypto.EncyptKText(SetupDatabaseHelper.SqlDbUserPassword);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CMPDBPASSWORDSTRING=\"{0}\" ", encryptedCmpDbPassword);

                // Encrypt the password of the sql user that will be used by the website to access CMP WAP DB
                //string encryptedCmpWapDbPassword = String.Format("{0}{1}{2}", "[KText]", UserAccountHelper.EncryptStringUsingLocalCertificate(SetupDatabaseHelper.SqlDbUserPassword, certificateThumbprint), "[KText]");
                string encryptedCmpWapDbPassword = krypto.EncyptKText(SetupDatabaseHelper.SqlDbUserPassword);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "CMPWAPDBPASSWORDSTRING=\"{0}\" ", encryptedCmpWapDbPassword);

                // Encrypt the password of the sql user that will be used by the website to access WAP's Microsoft.MgmtSvc.Store DB
                //string encryptedMgmtStoreDbPassword = String.Format("{0}{1}{2}", "[KText]", UserAccountHelper.EncryptStringUsingLocalCertificate(SetupDatabaseHelper.SqlDbUserPassword, certificateThumbprint), "[KText]");
                string encryptedMgmtStoreDbPassword = krypto.EncyptKText(SetupDatabaseHelper.SqlDbUserPassword);
                arguments.AppendFormat(CultureInfo.InvariantCulture, "MGMTSTOREPASSWORDSTRING=\"{0}\" ", encryptedMgmtStoreDbPassword);
            }

            return(arguments.ToString());
        }
예제 #6
0
        /// <summary>
        /// Loads the paramneters into wizard inputs
        /// </summary>
        /// <param name="parameterList"></param>
        public void LoadParameterList(StringCollection parameterList)
        {
            if (parameterList == null)
            {
                throw new ArgumentNullException("parameterList");
            }

            this.parameterList = parameterList;

            InputParameter inputParameter = null;

            foreach (String parameter in parameterList)
            {
                switch (parameter)
                {
                case SetupInputTags.SetupUserAccountTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SetupUserAccount());
                    break;
                }

                case SetupInputTags.UserNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new UserName());
                    break;
                }

                case SetupInputTags.BinaryInstallLocationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new BinaryInstallLocation());
                    break;
                }

                case SetupInputTags.CreateNewSqlDatabaseTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new CreateNewSqlDatabase());
                    break;
                }

                case SetupInputTags.RetainSqlDatabaseTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new RetainSqlDatabase());
                    break;
                }

                case SetupInputTags.SqlInstanceNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlInstanceName());
                    break;
                }

                case SetupInputTags.SqlDatabaseNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDatabaseName());
                    break;
                }

                case SetupInputTags.RemoteDatabaseImpersonationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new RemoteDatabaseImpersonation());
                    break;
                }

                case SetupInputTags.SqlMachineNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlMachineName());
                    break;
                }

                case SetupInputTags.SqlDBAdminNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDBAdminName());
                    break;
                }

                case SetupInputTags.SqlDBAdminPasswordTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDBAdminPassword());
                    break;
                }

                case SetupInputTags.SqlDBAdminDomainTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDBAdminDomain());
                    break;
                }

                case SetupInputTags.SqlServerPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlServerPort());
                    break;
                }

                case SetupInputTags.WapCreateNewSqlDatabaseTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapCreateNewSqlDatabase());
                    break;
                }

                case SetupInputTags.WapRetainSqlDatabaseTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapRetainSqlDatabase());
                    break;
                }

                case SetupInputTags.WapSqlInstanceNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapSqlInstanceName());
                    break;
                }

                case SetupInputTags.WapSqlDatabaseNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapSqlDatabaseName());
                    break;
                }

                case SetupInputTags.WapRemoteDatabaseImpersonationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapRemoteDatabaseImpersonation());
                    break;
                }

                case SetupInputTags.WapSqlMachineNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapSqlMachineName());
                    break;
                }

                case SetupInputTags.WapSqlDBAdminNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapSqlDBAdminName());
                    break;
                }

                case SetupInputTags.WapSqlDBAdminPasswordTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapSqlDBAdminPassword());
                    break;
                }

                case SetupInputTags.WapSqlDBAdminDomainTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapSqlDBAdminDomain());
                    break;
                }

                case SetupInputTags.WapSqlServerPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WapSqlServerPort());
                    break;
                }

                case SetupInputTags.SqlDataFileLocationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlFileLocation());
                    break;
                }

                case SetupInputTags.SqlLogFileLocationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlFileLocation());
                    break;
                }

                case SetupInputTags.CmpServerNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new CmpServerName());
                    break;
                }

                case SetupInputTags.CmpCertificateThumbprintTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new CmpCertificateThumbprint());
                    break;
                }

                case SetupInputTags.CmpServiceLocalAccountTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new CmpServiceLocalAccount());
                    break;
                }

                case SetupInputTags.CmpServiceDomainTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServiceDomain());
                    break;
                }

                case SetupInputTags.CmpServiceUserNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServiceUserName());
                    break;
                }

                case SetupInputTags.CmpServiceUserPasswordTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServiceUserPassword());
                    break;
                }

                default:
                {
                    throw new ArgumentException("Unknown parameter");
                    break;
                }
                }

                // Initialize all the parameters to defaults
                inputParameter = this.FindItem(parameter);
                inputParameter.ResetToDefault();
            }
        }