Exemple #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            foreach (DomainController dc in pfHelper.AllDomainControllers)
            {
                foreach (string dcActive in ConfiguredDomainControllersList)
                {
                    if (dcActive == dc.Name)
                    {
                        string dcIpAddress = dc.IPAddress;
                        try
                        {
                            string sysPath          = pfHelper.getSysPath(dcIpAddress);
                            string sysDrive         = sysPath.Split(':')[0];
                            string remoteRootFolder = @"\\" + dcIpAddress + @"\" + sysDrive + @"$\";
                            string remoteEpfFolder  = remoteRootFolder + @"epf";

                            if (!Directory.Exists(remoteEpfFolder))
                            {
                                Directory.CreateDirectory(remoteEpfFolder);
                            }

                            foreach (string dirPath in Directory.GetDirectories(Properties.Settings.Default.EpfFilesPath, "*", SearchOption.AllDirectories))
                            {
                                Directory.CreateDirectory(dirPath.Replace(Properties.Settings.Default.EpfFilesPath, remoteEpfFolder));
                            }

                            foreach (string newPath in Directory.GetFiles(Properties.Settings.Default.EpfFilesPath, "*.*", SearchOption.AllDirectories))
                            {
                                File.Copy(newPath, newPath.Replace(Properties.Settings.Default.EpfFilesPath, remoteEpfFolder), true);
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Error copying password files to " + dc.Name);
                        }
                    }
                }
            }

            MessageBox.Show("Done copying password files!");
        }
Exemple #2
0
        //Install Button
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string selectedModule = "";

            try
            {
                selectedModule = this.installDomainControllers.SelectedValue.ToString().Split(':')[0].Trim();
            }
            catch
            {
                MessageBox.Show("Invalid Selection");
                return;
            }

            string dcIpAddress = "";
            bool   is64bit     = false;
            string sysPath     = "";
            string dcName      = "";

            foreach (DomainController dc in pfHelper.AllDomainControllers)
            {
                if (dc.Name == selectedModule)
                {
                    dcName = dc.Name;

                    dcIpAddress = dc.IPAddress;

                    is64bit = pfHelper.checkArch(dcIpAddress).Contains("64");

                    sysPath = pfHelper.getSysPath(dcIpAddress);
                }
            }

            if (pfHelper.updateRegValue(dcIpAddress, false))
            {
                reInit();
            }

            string sysDrive         = sysPath.Split(':')[0];
            string sysFolder        = sysPath.Split(':')[1].Split('\\')[1] + @"\system32";
            string remoteRootFolder = @"\\" + dcName + @"\" + sysDrive + @"$\";
            string remoteEpfFolder  = remoteRootFolder + @"epf";
            string remoteSysFolder  = remoteRootFolder + sysFolder + @"\EasyPasswordFilter.dll";

            try
            {
                if (!Directory.Exists(remoteEpfFolder))
                {
                    Directory.CreateDirectory(remoteEpfFolder);
                }

                foreach (string dirPath in Directory.GetDirectories(Properties.Settings.Default.EpfFilesPath, "*", SearchOption.AllDirectories))
                {
                    Directory.CreateDirectory(dirPath.Replace(Properties.Settings.Default.EpfFilesPath, remoteEpfFolder));
                }

                foreach (string newPath in Directory.GetFiles(Properties.Settings.Default.EpfFilesPath, "*.*", SearchOption.AllDirectories))
                {
                    File.Copy(newPath, newPath.Replace(Properties.Settings.Default.EpfFilesPath + "\\", remoteEpfFolder + "\\"), true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error copying password list");
                MessageBox.Show(ex.ToString());
            }

            if (File.Exists(remoteSysFolder))
            {
                try
                {
                    File.Delete(remoteSysFolder);
                }
                catch
                {
                    MessageBox.Show("Could not delete EasyPasswordFilter.dll, try restarting the Domain Controller");
                }
            }

            if (is64bit)
            {
                try
                {
                    File.Copy(Properties.Settings.Default.EasyPasswordFilterDllLocationx64, remoteSysFolder);
                }
                catch
                {
                    MessageBox.Show("Error deploying EasyPasswordFilter.dll...possibly already exists");
                }
            }
            else
            {
                try
                {
                    File.Copy(Properties.Settings.Default.EasyPasswordFilterDllLocationx86, remoteSysFolder);
                }
                catch
                {
                    MessageBox.Show("Error deploying EasyPasswordFilter.dll...possibly already exists");
                }
            }

            MessageBoxResult msgBoxRes = MessageBox.Show("System Updated, Restart " + dcName + "?", "Confirm DC Restart", MessageBoxButton.YesNo);

            if (msgBoxRes == MessageBoxResult.Yes)
            {
                try
                {
                    Process rstProc = new Process();
                    rstProc.EnableRaisingEvents = false;
                    rstProc.StartInfo.FileName  = "cmd.exe";
                    rstProc.StartInfo.Arguments = @"/c shutdown -r -t 0 -f -m \\" + dcIpAddress;
                    rstProc.Start();
                    MessageBox.Show(dcName + " Restarted");
                }
                catch
                {
                    MessageBox.Show("Error restarting " + dcName);
                }
            }
        }