Пример #1
0
        public ServerStatusActionResult RepairBindConfig()
        {
            WindowsUser namedUser = findWindowsUser();

            if (namedUser == null)
            {
                throw new Exception(
                          "Cannot repair when user '" + iscBindUser + "' does not exist.");
            }

            string       iscBindDirectory = ServerConfig.IscBindDirectory.FullName;
            IscBindSetup bindSetup        = new IscBindSetup(iscBindDirectory, namedUser.Sid);

            // Backup existing configs and replace with new one.
            bindSetup.InitializeConfig();

            // Regenerate zone config file in case it's corrupt.
            IscBindManager bindManager = CreateManager <IscBindManager>();

            bindManager.RegenerateMainConfigFile();

            ServiceController sc = getIscBindServiceController();

            if (sc.Status == ServiceControllerStatus.Running)
            {
                sc.Stop();
                sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
            }

            sc.Start();
            sc.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10));

            ServerStatusActionResult result = new ServerStatusActionResult();

            if (sc.Status == ServiceControllerStatus.Running)
            {
                result.Success     = true;
                result.UserMessage = "The configuration was repaired, and the ISC BIND service was restarted.";
            }
            else
            {
                result.Success = false;
                if (getIscBindConfigStatus().Condition == ServerStatusCondition.Normal)
                {
                    result.UserMessage = "The repair was successful, but the ISC BIND service did not start.";
                }
                else
                {
                    result.UserMessage = "The repair has failed, and the ISC BIND service failed to start.";
                }
            }

            return(result);
        }
Пример #2
0
 void WebsiteManager_Load(object sender, EventArgs e)
 {
     wuManager  = new WindowsUserManager(ServerConfig.WindowsServerName);
     dnsManager = CreateManager <IscBindManager>();
     iisManager = new ServerManager();
 }