Пример #1
0
        /// <summary>
        /// Validates the inputs on this page
        /// </summary>
        /// <returns></returns>
        public override bool ValidatePage()
        {
            bool isPageValid = true;

            try
            {
                if (this.checkBoxNewUserId.IsChecked.GetValueOrDefault(false))
                {
                    String userName   = SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDBAdminNameTag);
                    String domainName = SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDBAdminDomainTag);
                    if (!UserAccountHelper.ValidateCredentials(userName, domainName, this.passwordBoxPassword.SecurePassword))
                    {
                        throw new Exception("Either the domain account or the password you entered are not valid.");
                    }
                }
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);

                isPageValid = false;
            }
            return(isPageValid);
        }
Пример #2
0
        private void textBoxUserName_LostFocus(object sender, EventArgs e)
        {
            try
            {
                String fullUserName = this.textBoxUserName.Text;

                string[] nameSplits = fullUserName.Split(SetupConstants.AccountDomainUserSeparator);
                if (nameSplits.Length == 1)
                {
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDBAdminDomainTag, String.Empty);
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDBAdminNameTag, nameSplits[0]);
                }
                else if (nameSplits.Length == 2)
                {
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDBAdminDomainTag, nameSplits[0]);
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDBAdminNameTag, nameSplits[1]);
                }
                else
                {
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDBAdminDomainTag, String.Empty);
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDBAdminNameTag, String.Empty);
                }
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);
            }

            this.SetNextButtonState();
        }
Пример #3
0
        private void passwordBox_PasswordChanged(object sender, EventArgs e)
        {
            try
            {
                SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDBAdminPasswordTag, this.passwordBoxPassword.SecurePassword);
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);
            }

            this.SetNextButtonState();
        }
Пример #4
0
        public static bool CMPServerPostinstallProcessor()
        {
            bool returnValue = true;

            try
            {
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
                {
                    String currentSetupUser = String.Format(SetupConstants.UserAccountTemplate, Environment.UserDomainName, Environment.UserName);
                    SetupInputs.Instance.EditItem(SetupInputTags.SetupUserAccountTag, currentSetupUser);

                    SetupDatabaseHelper.CheckDatabase(
                        InstallItemCustomDelegates.GetSQLServerInstanceNameStr(false),
                        SetupInputs.Instance.FindItem(SetupInputTags.SqlDatabaseNameTag),
                        false);

                    SetupDatabaseHelper.CreateDB(false);

                    if (SetupInputs.Instance.FindItem(SetupInputTags.RemoteDatabaseImpersonationTag))
                    {
                        SetupDatabaseHelper.GrantSetupUserDBAccess(true, false);
                        SetupInputs.Instance.EditItem(SetupInputTags.RemoteDatabaseImpersonationTag, false);
                        PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.AfterGrantSetupUserDBAccess, true);
                    }

                    ServiceConfigurationHandler serviceConfigurationHandler = new ServiceConfigurationHandler();
                    CmpWorkerServiceHelper.ConfigureCMPWorkerService(serviceConfigurationHandler);

                    serviceConfigurationHandler.StartService(SetupConstants.EngineServiceName);
                }
            }
            catch (Exception exception)
            {
                SetupLogger.LogException(exception, "CMPServerPostinstallProcessor threw an exception");
                PropertyBagDictionary.Instance.SafeAdd(PropertyBagDictionary.VitalFailure,
                                                       (PropertyBagDictionary.Instance.PropertyExists(PropertyBagDictionary.VitalFailure)
                    ? (PropertyBagDictionary.Instance.GetProperty <InstallItemsInstallDataItem.InstallDataInputs>
                           (PropertyBagDictionary.VitalFailure) | InstallItemsInstallDataItem.InstallDataInputs.PostInstallItem)
                    : InstallItemsInstallDataItem.InstallDataInputs.PostInstallItem));
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason))
                {
                    PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception);
                }
                returnValue = false;
            }

            return(returnValue);
        }
        private void comboBoxInstance_DropDownOpened(object sender, EventArgs e)
        {
            this.DisableInputMode();
            String[] instanceArray = null;
            try
            {
                this.resetServerName();
                if (!String.IsNullOrEmpty(this.serverName))
                {
                    using (ImpersonationHelper impersonationHelper = new ImpersonationHelper())
                    {
                        //PropertyBagDictionary.Instance.SafeAdd("SQLMachineName", this.serverName);
                        instanceArray = SetupDatabaseHelper.GetSqlInstanceNames(this.serverName);
                    }
                }
                this.comboBoxInstance.Text = String.Empty;
                this.comboBoxInstance.Items.Clear();
                if (instanceArray != null && instanceArray.Length > 0)
                {
                    foreach (String instanceName in instanceArray)
                    {
                        this.comboBoxInstance.Items.Add(instanceName);
                    }

                    if (this.comboBoxInstance.Items.Contains(this.selectedInstance))
                    {
                        this.comboBoxInstance.Text = this.selectedInstance;
                    }
                    else
                    {
                        this.selectedInstance      = instanceArray[0];
                        this.comboBoxInstance.Text = this.selectedInstance;
                    }
                }
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);
            }

            this.EnableInputMode();
        }
 private void passwordBox_LostFocus(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.checkBoxNewUserId.IsChecked.GetValueOrDefault(false) &&
             !string.IsNullOrEmpty(this.textBoxUserName.Text.Trim()))
         {
             String userName   = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminNameTag);
             String domainName = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminDomainTag);
             if (!UserAccountHelper.ValidateCredentials(userName, domainName, this.passwordBoxPassword.SecurePassword))
             {
                 throw new Exception("Either the domain account or the password you entered are not valid");
             }
         }
     }
     catch (Exception backEndErrorException)
     {
         SetupLogger.LogException(backEndErrorException);
         SetupHelpers.ShowError(backEndErrorException.Message);
     }
 }
Пример #7
0
        private void ShowFreeSpace()
        {
            try
            {
                ulong  OneMB     = 1024 * 1024;
                UInt64 freeSpace = 0;
                String path      = this.textBoxInstallationLocation.Text;

                SetupInputs.Instance.EditItem(SetupInputTags.BinaryInstallLocationTag, path);

                freeSpace = InstallLocationValidation.Instance.GetFreeDiskSpace(path);
                ulong      spaceInByte     = (ulong)freeSpace * OneMB;
                SizeFormat space           = new SizeFormat((long)spaceInByte);
                String     freeSpaceAsText = space.FormatSizeWithLabel((long)spaceInByte);

                this.textBlockFreeSpace.Text = String.Format(WpfResources.WPFResourceDictionary.FreeSpace, freeSpaceAsText);
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);
            }
        }
Пример #8
0
        public override bool ValidatePage()
        {
            try
            {
                String selectedLocation = this.textBoxInstallationLocation.Text;
                if (!selectedLocation.EndsWith(Path.DirectorySeparatorChar.ToString()))
                {
                    selectedLocation = selectedLocation + Path.DirectorySeparatorChar.ToString();
                }

                // If this is an upgrade, we cannot let the user choose the same location as
                // the previous installation
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.VMMSupportedVersionInstalled))
                {
                    if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.ServerVersion) &&
                        selectedLocation.Equals(SetupConstants.GetServerInstallPath(), StringComparison.OrdinalIgnoreCase))
                    {
                        throw new Exception("An installation already exists at this location");
                    }
                }

                SetupInputs.Instance.EditItem(SetupInputTags.BinaryInstallLocationTag, selectedLocation);

                // Need to save the installation location in property bag for prerequisite check
                PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.InstallationLocation, this.textBoxInstallationLocation.Text);
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);

                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Validates the inputs on this page
        /// </summary>
        /// <returns></returns>
        public override bool ValidatePage()
        {
            bool isPageValid = true;

            try
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                SetupInputs.Instance.EditItem(SetupInputTags.WapSqlMachineNameTag, this.textBoxServer.Text);
                SetupInputs.Instance.EditItem(SetupInputTags.WapSqlInstanceNameTag,
                                              IsDefaultInstance(this.comboBoxInstance.Text) ? String.Empty : this.comboBoxInstance.Text);

                this.port = String.IsNullOrEmpty(this.textBoxPort.Text) ?
                            InputDefaults.WapSqlServerPort : Convert.ToInt32(this.textBoxPort.Text);
                SetupInputs.Instance.EditItem(SetupInputTags.WapSqlServerPortTag, this.port);

                bool isNewDB = this.radioNewDatabase.IsChecked.GetValueOrDefault(false);

                SetupInputs.Instance.EditItem(SetupInputTags.WapCreateNewSqlDatabaseTag, isNewDB);

                if (isNewDB)
                {
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDatabaseNameTag, this.textBoxNewDatabaseName.Text);
                }
                else
                {
                    SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDatabaseNameTag, this.comboBoxExistingDatabaseName.Text);
                }

                if (this.checkBoxNewUserId.IsChecked.GetValueOrDefault(false))
                {
                    String userName   = SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDBAdminNameTag);
                    String domainName = SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDBAdminDomainTag);
                    if (!UserAccountHelper.ValidateCredentials(userName, domainName, this.passwordBoxPassword.SecurePassword))
                    {
                        throw new Exception("Either the domain account or the password you entered are not valid.");
                    }
                }

                String fullInstanceName = SetupDatabaseHelper.ConstructFullInstanceName(
                    !SetupDatabaseHelper.SqlServerIsOnLocalComputer(this.serverName),
                    (String)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlMachineNameTag),
                    (String)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlInstanceNameTag),
                    (int)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlServerPortTag));

                SetupDatabaseHelper.CheckDatabase(
                    fullInstanceName,
                    (String)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDatabaseNameTag),
                    true);
            }
            catch (SqlException)
            {
                Exception exception = new Exception("Setup cannot connect to the specified SQL Server instance.");

                SetupLogger.LogException(exception);
                SetupHelpers.ShowError(exception.Message);

                isPageValid = false;
            }
            catch (Exception exception)
            {
                SetupLogger.LogException(exception);
                SetupHelpers.ShowError(exception.Message);

                isPageValid = false;
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }

            return(isPageValid);
        }
Пример #10
0
        public static bool CMPServerPreinstallProcessor()
        {
            bool returnValue = true;

            try
            {
                InstallItemsInstallDataItem virtualMachineManagerInstallItem = null;

                // Find the installdata item in the array
                foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall))
                {
                    if (string.Equals(itemToInstall.ControlTitle, PropertyBagConstants.CMPServer, StringComparison.OrdinalIgnoreCase))
                    {
                        virtualMachineManagerInstallItem = itemToInstall;
                        break;
                    }
                }

                if (virtualMachineManagerInstallItem == null)
                {
                    // Item not found - throw an exception
                    SetupLogger.LogError("PageCustomDelegates: VMMPreinstallProcessor: Install Data item not found.");
                    throw new ArgumentException(WpfResources.WPFResourceDictionary.InvalidArgument);
                }

                // Set the Install/Uninstall state
                virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue = virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue |
                                                                                (PropertyBagDictionary.Instance.PropertyExists("uninstall") ? InstallItemsInstallDataItem.InstallDataInputs.Uninstalling : InstallItemsInstallDataItem.InstallDataInputs.Installing);

                // If this is not an uninstall, remove the product code.
                if (0 == (virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue & InstallItemsInstallDataItem.InstallDataInputs.Uninstalling))
                {
                    virtualMachineManagerInstallItem.ProductCode = string.Empty;
                }

                // Set the location of the log file
                virtualMachineManagerInstallItem.LogFile = SetupHelpers.SetLogFilePath(virtualMachineManagerInstallItem.LogFile);

                SetupHelpers.CreateEventSources();

                // Adjust the command line arguments
                virtualMachineManagerInstallItem.Arguments += InstallItemCustomDelegates.ConfigureBasicCommandLineArguments() + InstallItemCustomDelegates.ConfigureServerCommandLineArguments();


                bool isRollback = PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.RollbacksToProcess);

                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
                {
                    String currentSetupUser = String.Format(SetupConstants.UserAccountTemplate, Environment.UserDomainName, Environment.UserName);
                    SetupInputs.Instance.EditItem(SetupInputTags.SetupUserAccountTag, currentSetupUser);

                    if (SetupInputs.Instance.FindItem(SetupInputTags.RemoteDatabaseImpersonationTag))
                    {
                        SetupDatabaseHelper.GrantSetupUserDBAccess(false, false);
                        SetupInputs.Instance.EditItem(SetupInputTags.RemoteDatabaseImpersonationTag, false);
                        PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.AfterGrantSetupUserDBAccess, true);
                    }

                    ServiceConfigurationHandler.RemoveService(SetupConstants.EngineServiceName);

                    // Stopping the service sometimes does not end the processes and this keeps a lock on the process binaries
                    InstallItemCustomDelegates.EndCmpWorkerServiceProcess();

                    bool retainDB = SetupInputs.Instance.FindItem(SetupInputTags.RetainSqlDatabaseTag) ||
                                    !SetupInputs.Instance.FindItem(SetupInputTags.CreateNewSqlDatabaseTag);

                    if (!retainDB)
                    {
                        SetupDatabaseHelper.RemoveDB(false);
                    }
                }
            }
            catch (ArgumentException exception)
            {
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason))
                {
                    PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception);
                }
                SetupLogger.LogException(exception);
                returnValue = false;
            }

            return(returnValue);
        }
Пример #11
0
        /// <summary>
        /// Validates the file exists on server.
        /// </summary>
        /// <param name="remoteComputer">The remote computer.</param>
        /// <param name="pathToCheck">The path to check.</param>
        /// <returns>
        /// true if there are files in the folder, false otherwise
        /// </returns>
        public static Collection <string> ListOfFilesOnRemoteComputer(string remoteComputer, string pathToCheck)
        {
            Collection <string> filesInFolder = null;

            if (string.IsNullOrEmpty(remoteComputer) || string.IsNullOrEmpty(pathToCheck))
            {
                SetupLogger.LogInfo("ValidateFileExistsOnServer: Either the computer name or the path to check was null.  We will return -1;");
                return(null);
            }

            try
            {
                pathToCheck = pathToCheck.Replace("\\", "\\\\");
                string remoteFolder = "ASSOCIATORS OF " +
                                      "{Win32_Directory=\"" + pathToCheck.TrimEnd(Path.DirectorySeparatorChar) + "\"} " +
                                      "WHERE AssocClass=CIM_DirectoryContainsFile " +
                                      "ResultClass=CIM_DataFile " +
                                      "ResultRole=PartComponent " +
                                      "Role=GroupComponent";

                ManagementObjectSearcher query = new ManagementObjectSearcher(remoteFolder);

                // Connect to the computer
                ConnectionOptions co = new ConnectionOptions();
                co.Impersonation = ImpersonationLevel.Impersonate;
                co.Timeout       = new TimeSpan(0, 0, 30);

                ManagementScope ms = new ManagementScope(
                    "\\\\" + remoteComputer + "\\root\\cimv2",
                    co);

                query.Scope = ms;
                ManagementObjectCollection queryCollection = query.Get();

                filesInFolder = new Collection <string>();

                foreach (ManagementObject mo in queryCollection)
                {
                    string fileExtension = (mo["Extension"].ToString());
                    if (fileExtension.Equals("mdf", StringComparison.OrdinalIgnoreCase) ||
                        fileExtension.Equals("ldf", StringComparison.OrdinalIgnoreCase))
                    {
                        filesInFolder.Add(mo["FileName"].ToString().ToLowerInvariant());
                    }
                }
            }
            catch (ArgumentException e)
            {
                SetupLogger.LogException(e);
            }
            catch (COMException e)
            {
                SetupLogger.LogException(e);
            }
            catch (UnauthorizedAccessException e)
            {
                SetupLogger.LogException(e);
            }
            catch (ManagementException e)
            {
                SetupLogger.LogException(e);
            }

            return(filesInFolder);
        }
Пример #12
0
        /// <summary>
        /// Validates the page.
        /// The default implementation always returns true for 'validated'.
        /// </summary>
        /// <returns>true if valid</returns>
        public override bool ValidatePage()
        {
            bool isPageValid = true;

            try
            {
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
                {
                    if (this.radioDomainAccount.IsChecked.GetValueOrDefault(false))
                    {
                        String fullUserName;

                        try
                        {
                            DnsHelper.CheckAndGetFullUserName(this.textBoxUserName.Text, out fullUserName);
                            fullUserName = this.textBoxUserName.Text;
                        }
                        catch
                        {
                            // Ignore failures
                            fullUserName = String.Empty;
                        }

                        string[] nameSplits = fullUserName.Split(SetupConstants.AccountDomainUserSeparator);
                        if (nameSplits.Length == 1)
                        {
                            SetupInputs.Instance.EditItem(SetupInputTags.CmpServiceDomainTag, String.Empty);
                            SetupInputs.Instance.EditItem(SetupInputTags.CmpServiceUserNameTag, nameSplits[0]);
                        }
                        else if (nameSplits.Length == 2)
                        {
                            SetupInputs.Instance.EditItem(SetupInputTags.CmpServiceDomainTag, nameSplits[0]);
                            SetupInputs.Instance.EditItem(SetupInputTags.CmpServiceUserNameTag, nameSplits[1]);
                        }
                        else
                        {
                            SetupInputs.Instance.EditItem(SetupInputTags.CmpServiceDomainTag, String.Empty);
                            SetupInputs.Instance.EditItem(SetupInputTags.CmpServiceUserNameTag, String.Empty);
                        }
                        SetupInputs.Instance.EditItem(
                            SetupInputTags.CmpServiceUserPasswordTag,
                            this.passwordBoxPassword.SecurePassword);

                        if (!this.TestCredential())
                        {
                            throw new Exception("Invalid service account");
                        }
                    }
                }

                // Only the certificate is selected for both server and extensions
                this.selectedCertificate = SetupInputs.Instance.FindItem(SetupInputTags.CmpCertificateThumbprintTag);
                this.certificateSelectionCombobox.Text = selectedCertificate;
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);

                isPageValid = false;
            }

            return(isPageValid);
        }