Exemplo n.º 1
0
        public override void Rollback(IDictionary savedState)
        {
            // make sure the connection string isn't in the LSA
            LSAUtil lsa = new LSAUtil();

            try
            {
                lsa.DeletePrivateKey();
                AMUser.DeleteUser();
                // continue rollback
                base.Rollback(savedState);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
            }

            try
            {
                // Remove the message queue, if it exists
                if (System.Messaging.MessageQueue.Exists(ACTION_QUEUE_PATH))
                {
                    System.Messaging.MessageQueue.Delete(ACTION_QUEUE_PATH);
                }
            }
            catch (Exception)
            {
                // Eat the exception.  We should not fail if we cannot remove the queue.
            }
        }
Exemplo n.º 2
0
        public override void Uninstall(IDictionary savedState)
        {
            System.Diagnostics.EventLog.WriteEntry("AMInstall", "Begin Uninstall");

            LSAUtil lsa = new LSAUtil();

            try
            {
                // remove the connection string stored in the LSA
                lsa.DeletePrivateKey();

                // remove the SSL Flag from the IIS Vdir if it was set
                if (Convert.ToBoolean(savedState[SSLEnabled]))
                {
                    Process          p;
                    string           filePath = savedState[installPath].ToString() + "Assignment Manager\\Setup";
                    ProcessStartInfo si       = new System.Diagnostics.ProcessStartInfo("\"" + filePath + "\\RemoveSSLFlag.vbs\"", "\"" + savedState[webName].ToString() + "\"");
                    si.WindowStyle = ProcessWindowStyle.Hidden;
                    try
                    {
                        p = Process.Start(si);
                        p.WaitForExit();
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.EventLog.WriteEntry("AMInstall", "Process Exception", System.Diagnostics.EventLogEntryType.Information);
                        throw new InstallException(e.Message);
                    }
                }
                AMUser.DeleteUser();                                                    //Also deletes the password stored in LSA

                try
                {
                    // if the Queue exists, then remove it.
                    if (System.Messaging.MessageQueue.Exists(ACTION_QUEUE_PATH))
                    {
                        System.Messaging.MessageQueue.Delete(ACTION_QUEUE_PATH);
                    }
                }
                catch (Exception)
                {
                    // Eat the exception.  We should not fail if we cannot remove the queue.
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
            }

            // continue uninstall
            base.Uninstall(savedState);
        }
Exemplo n.º 3
0
        private string generateDBPwd()
        {
            string tempPwd = AMUser.CreatePassword(30);             // Create a strong password of length 30
            string pwd     = "";

            for (int i = 0; i < tempPwd.Length; i++)
            {
                // we need to skip characters that cause SQL problems when used in a pwd
                char charCode = tempPwd[i];
                // blocks: ';,`="
                if ((charCode == 39) || (charCode == 59) || (charCode == 44) || (charCode == 96) || (charCode == 61) || (charCode == 34))
                {
                    continue;
                }
                else
                {
                    pwd += tempPwd[i];
                }
            }
            return(pwd);
        }
Exemplo n.º 4
0
        public override void Install(System.Collections.IDictionary savedState)
        {
            String args = this.Context.Parameters["Args"];

            String[] individualArgs;
            String   filePath    = "";
            string   installUser = "";
            string   installPwd  = "";

            individualArgs = args.Split(Convert.ToChar(","));
            if (args == "")
            {
                // throw an exception, we're expecting parameters/argumen
                throw new InstallException("No arguments specified");
            }

            // store the setup options we need for uninstall
            if (!saveInstallState(savedState, individualArgs))
            {
                throw new InstallException("Can't persist install parameters");
            }

            // valid arguments, do the install work
            filePath = individualArgs[(int)InstallParams.ProgramFilesFolder] + "Assignment Manager\\Setup";
            // grab the db install user/pwd
            installUser = individualArgs[(int)InstallParams.DBUserID];
            installPwd  = individualArgs[(int)InstallParams.DBPassword];

            if (individualArgs[(int)InstallParams.TargetVDir] == "")
            {
                throw new InstallException("individualArgs[VDir] = " + individualArgs[(int)InstallParams.TargetVDir] +
                                           "\nargs[web] = " + individualArgs[(int)InstallParams.TargetWebDirectory]);
            }

            // create the db
            if (!createDB(individualArgs))
            {
                throw new  InstallException("Error occured creating the database");
            }

            // do the web site config
            Process p2;
            string  targetVDir = individualArgs[(int)InstallParams.TargetVDir];
            string  sslValue   = getBooleanValue(individualArgs[(int)InstallParams.SSLEnabled]);

            ProcessStartInfo si2 = new System.Diagnostics.ProcessStartInfo("\"" + filePath + "\\RemoveScriptMaps.vbs\"", "\"" + targetVDir + "\" \"" + sslValue + "\"");

            si2.WindowStyle = ProcessWindowStyle.Hidden;
            try
            {
                p2 = Process.Start(si2);
                p2.WaitForExit();
            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", ex.ToString());
                throw new InstallException(ex.Message);
            }


            try
            {
                createApplicationPool(appPoolName);
                if (DirectoryEntry.Exists("IIS://localhost/w3svc/AppPools/AssignmentManager"))
                {
                    // if Application Pools exist, then add AssignmentManager to our newly created pool
                    addVDirToAppPool(individualArgs[(int)InstallParams.TargetVDir], appPoolName);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", ex.ToString());
            }


            // Set the upload directory to Read/Write/Delete for Everyone, Full Control for System.
            if (!SecurityPermissions.SetVDirSecurityDescriptor("AMUpload", "D:(A;OICI;GWGRSD;;;WD)(A;OICI;GA;;;SY)"))
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Unable to set the AMUpload directory writeable for Everyone.");
            }
            // Set the download directory to Full Control for Local System, Read/Delete for Everyone.
            if (!SecurityPermissions.SetVDirSecurityDescriptor("AMDownload", "D:(A;OICI;GA;;;SY)(A;OICI;GRSD;;;WD)"))
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Unable to set permissions on the AMDownload directory.");
            }

            // update the web.config file
            if (!updateConfigFile(individualArgs[(int)InstallParams.TargetWebDirectory] + "web.config", individualArgs))
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Error occured while updating configuration files", System.Diagnostics.EventLogEntryType.Error);
                throw new InstallException();
            }

            // update the ActionService.exe.config file
            if (!updateConfigFile(individualArgs[(int)InstallParams.ProgramFilesFolder] + "Assignment Manager\\Controller\\ActionService.exe.config", individualArgs))
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Error occured while updating application configuration files", System.Diagnostics.EventLogEntryType.Error);
                throw new InstallException();
            }

            // update the Controller.exe.config file
            if (!updateConfigFile(individualArgs[(int)InstallParams.ProgramFilesFolder] + "Assignment Manager\\Controller\\Controller.exe.config", individualArgs))
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Error occured while updating application configuration files", System.Diagnostics.EventLogEntryType.Error);
                throw new InstallException();
            }

            if (!AMUser.CreateUser())
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Error occured while creating the AssignmentManager user", System.Diagnostics.EventLogEntryType.Error);
                throw new InstallException();
            }

            if (!AMUser.AddUserToGroup())
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Error occured while addding the AssignmentManager user to the Users group", System.Diagnostics.EventLogEntryType.Error);
                throw new InstallException();
            }

            //Create data directory
            if (!CreateDataDirectory())
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Cannot create c:\\data directory.", System.Diagnostics.EventLogEntryType.Error);
                throw new InstallException();
            }

            if (!setASPNETProcessInfinite())
            {
                // Do not abort in this case; they can still continue with installation.
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Unable to set the ASP .NET worker process timeout to Infinite.", System.Diagnostics.EventLogEntryType.Warning);
            }

            // Change process model to run as Local System
            if (!changeASPNETProcessModel())
            {
                // Do not abort on this case; the user may have custom set their machine.config file.
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Cannot change the ASP.NET Process model in machine.config", EventLogEntryType.Information);
            }

            string acl = "D:"                         // DACL
                         + "(A;OICI;GA;;;SY)"         // Local System full control
                         + "(A;OICI;GA;;;BA)"         // Administrators full control
                         + "(A;OICI;GR;;;WD)";        // Everyone Read

            if (!SecurityPermissions.RecurseAndSetSecurity(individualArgs[(int)InstallParams.TargetWebDirectory], acl))
            {
                System.Diagnostics.EventLog.WriteEntry("AMInstall", "Cannot change permissions on " + individualArgs[(int)InstallParams.TargetWebDirectory]);
            }

            base.Install(savedState);
        }