コード例 #1
0
        /// <summary>
        /// Initialize method implementation
        /// </summary>
        public static void Initialize(MFAConfig config)
        {
            WebAdminClient manager = new WebAdminClient();

            try
            {
                manager.Initialize();
                IWebAdminServices client = manager.Open();
                try
                {
                    var servernames = (from server in config.Hosts.ADFSFarm.Servers
                                       select(server.FQDN.ToLower(), server.NodeType.ToLower().Equals("primarycomputer")));

                    Dictionary <string, bool> dic = servernames.ToDictionary(pair => pair.Item1, pair => pair.Item2);
                    client.Initialize(dic);
                }
                catch (Exception)
                {
                    manager.UnInitialize();
                    return;
                }
                finally
                {
                    manager.Close(client);
                }
            }
            catch (Exception)
            {
                return;
            }
            return;
        }
コード例 #2
0
        /// <summary>
        /// GetAdministrativeACL method implmentation
        /// </summary>
        public static ACLParametersRecord GetAdministrativeACL(MFAConfig config)
        {
            WebAdminClient manager = new WebAdminClient();

            try
            {
                manager.Initialize();
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetAdministrativeACL(config.Hosts.ActiveDirectoryHost.DomainName, config.Hosts.ActiveDirectoryHost.Account, config.Hosts.ActiveDirectoryHost.Password, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + Path.DirectorySeparatorChar + "MFA"));
                }
                catch (Exception)
                {
                    manager.UnInitialize();
                    return(new ACLParametersRecord()
                    {
                        Loaded = false
                    });
                }
                finally
                {
                    manager.Close(client);
                }
            }
            catch (Exception)
            {
                return(new ACLParametersRecord()
                {
                    Loaded = false
                });
            }
        }
コード例 #3
0
        /// <summary>
        /// GetSIDsInformations method implmentation
        /// </summary>
        public static SIDsParametersRecord GetSIDsInformations(MFAConfig config)
        {
            // if (ClientSIDsProxy.Loaded)
            //     return ClientSIDsProxy.Record;
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetSIDsInformations(GetServers(config)));
                }
                catch (Exception)
                {
                    return(new SIDsParametersRecord()
                    {
                        Loaded = false
                    });
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #4
0
        /// <summary>
        /// GetAllComputerInformations method implementation
        /// </summary>
        internal Dictionary <string, ADFSServerHost> GetAllComputerInformations(Dictionary <string, bool> servers)
        {
            string        fqdn        = Dns.GetHostEntry("localhost").HostName.ToLower();
            List <string> servernames = (from server in servers
                                         where (server.Key.ToLower() != fqdn.ToLower())
                                         select server.Key.ToLower()).ToList <string>();

            Dictionary <string, ADFSServerHost> dict = new Dictionary <string, ADFSServerHost>();
            RegistryVersion     reg      = new RegistryVersion();
            string              nodetype = GetLocalNodeType();
            ADFSNodeInformation node     = GetLocalNodeInformations(reg, fqdn);

            node.NodeType = nodetype;

            dict.Add(fqdn, new ADFSServerHost()
            {
                FQDN                      = fqdn,
                BehaviorLevel             = node.BehaviorLevel,
                HeartbeatTmeStamp         = node.HeartbeatTmeStamp,
                NodeType                  = node.NodeType,
                CurrentVersion            = reg.CurrentVersion,
                CurrentBuild              = reg.CurrentBuild,
                InstallationType          = reg.InstallationType,
                ProductName               = reg.ProductName,
                CurrentMajorVersionNumber = reg.CurrentMajorVersionNumber,
                CurrentMinorVersionNumber = reg.CurrentMinorVersionNumber
            });
            foreach (string srv in servernames)
            {
                WebAdminClient manager = new WebAdminClient();
                manager.Initialize(srv);
                try
                {
                    IWebAdminServices client = manager.Open();
                    try
                    {
                        dict.Add(srv, client.GetComputerInformations(srv, false));
                    }
                    catch (EndpointNotFoundException nf)
                    {
                        _log.WriteEntry(nf.Message, EventLogEntryType.Error, 2010);
                        continue;
                    }
                    finally
                    {
                        manager.Close(client);
                    }
                }
                finally
                {
                    manager.UnInitialize();
                }
            }
            return(dict);
        }
コード例 #5
0
        /// <summary>
        /// ExportMailTemplates method implementation
        /// </summary>
        public static bool ExportMailTemplates(MFAConfig config, int lcid, Dictionary <string, string> data)
        {
            bool done = false;

            try
            {
                WebAdminClient manager = new WebAdminClient();
                try
                {
                    manager.Initialize();
                    IWebAdminServices client = manager.Open();
                    try
                    {
                        done = client.ExportMailTemplates(GetServers(config), CFGReaderUtilities.GetCryptedConfig(config), lcid, data);
                    }
                    finally
                    {
                        manager.Close(client);
                    }
                }
                finally
                {
                    manager.UnInitialize();
                }

                if (done)
                {
                    char   sep      = Path.DirectorySeparatorChar;
                    string htmlpath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + sep + "MFA" + sep + "MailTemplates" + sep + lcid.ToString();

                    MailProvider mailprov = config.MailProvider;
                    if (!mailprov.MailOTPContent.Exists(c => c.LCID.Equals(lcid)))
                    {
                        mailprov.MailOTPContent.Add(new SendMailFileName(lcid, htmlpath + sep + "MailOTPContent.html"));
                    }
                    if (!mailprov.MailKeyContent.Exists(c => c.LCID.Equals(lcid)))
                    {
                        mailprov.MailKeyContent.Add(new SendMailFileName(lcid, htmlpath + sep + "MailKeyContent.html"));
                    }
                    if (!mailprov.MailAdminContent.Exists(c => c.LCID.Equals(lcid)))
                    {
                        mailprov.MailAdminContent.Add(new SendMailFileName(lcid, htmlpath + sep + "MailAdminContent.html"));
                    }
                    if (!mailprov.MailNotifications.Exists(c => c.LCID.Equals(lcid)))
                    {
                        mailprov.MailNotifications.Add(new SendMailFileName(lcid, htmlpath + sep + "MailNotifications.html"));
                    }
                }
                return(done);
            }
            catch
            {
                return(false);
            }
        }
コード例 #6
0
        /// <summary>
        /// GetRemoteSIDsInformations method implmentation
        /// </summary>
        private SIDsParametersRecord GetRemoteSIDsInformations(Dictionary <string, bool> servers)
        {
            SIDsParametersRecord retvalue = null;

            try
            {
                retvalue = SIDs.GetSIDs();
                if (retvalue == null)
                {
                    string fqdn = Dns.GetHostEntry("localhost").HostName;
                    foreach (var srv in servers)
                    {
                        if (srv.Key.ToLower().Equals(fqdn.ToLower()) || (!srv.Value))
                        {
                            continue;
                        }
                        WebAdminClient manager = new WebAdminClient();
                        manager.Initialize(srv.Key);
                        try
                        {
                            IWebAdminServices client = manager.Open();
                            try
                            {
                                retvalue = client.RequestSIDsInformations();
                                SIDs.Assign(retvalue);
                                break; // Break on first primary server;
                            }
                            finally
                            {
                                manager.Close(client);
                            }
                        }
                        catch (Exception e)
                        {
                            _log.WriteEntry(string.Format("Error on WebAdminService Service GetRemoteSIDsInformations method : {0} / {1}.", srv, e.Message), EventLogEntryType.Error, 2010);
                        }
                        finally
                        {
                            manager.UnInitialize();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _log.WriteEntry(string.Format("Error on WebAdminService Service GetLocalSIDsInformations method : {0}.", e.Message), EventLogEntryType.Error, 2010);
                throw e;
            }
            return(retvalue);
        }
コード例 #7
0
        /// <summary>
        /// DoRequestAdministrativeACL method implementation
        /// </summary>
        private ACLParametersRecord DoRequestAdministrativeACL(Dictionary <string, bool> servers, string domain, string account, string password, string path)
        {
            string        fqdn        = Dns.GetHostEntry("localhost").HostName;
            List <string> servernames = (from server in servers
                                         where (server.Key.ToLower() != fqdn.ToLower() && (server.Value == true))
                                         select server.Key.ToLower()).ToList <string>();

            if (servernames != null)
            {
                foreach (string srvfqdn in servernames)
                {
                    WebAdminClient webthemeclient = new WebAdminClient();
                    try
                    {
                        webthemeclient.Initialize(srvfqdn);
                        IWebAdminServices client = webthemeclient.Open();
                        try
                        {
                            ACLParametersRecord rec = client.GetAdministrativeACL(domain, account, password, path);
                            if (rec.Loaded)
                            {
                                Certs.ApplyACLs(rec, path);
                            }
                            return(rec);
                        }
                        catch (Exception e)
                        {
                            webthemeclient.UnInitialize();
                            _log.WriteEntry(string.Format("Error calling  DoRequestAdministrativeACL method : {0} => {1}.", srvfqdn, e.Message), EventLogEntryType.Error, 2011);
                        }
                        finally
                        {
                            webthemeclient.Close(client);
                        }
                    }
                    catch (Exception e)
                    {
                        _log.WriteEntry(string.Format("Error calling  DoRequestAdministrativeACL method : {0} => {1}.", srvfqdn, e.Message), EventLogEntryType.Error, 2011);
                        return(new ACLParametersRecord()
                        {
                            Loaded = false
                        });
                    }
                }
            }
            return(new ACLParametersRecord()
            {
                Loaded = false
            });
        }
コード例 #8
0
        /// <summary>
        /// GetComputerInformations method implementation
        /// </summary>
        internal ADFSNodeInformation GetNodeInformations(RegistryVersion reg, string servername, bool dispatch = true)
        {
            string fqdn = Dns.GetHostEntry("localhost").HostName.ToLower();

            if (fqdn.ToLower().Equals(servername.ToLower()))
            {
                string nodetype          = GetLocalNodeType();
                ADFSNodeInformation node = GetLocalNodeInformations(reg, servername);
                node.NodeType = nodetype;
                return(node);
            }
            else
            {
                if (dispatch)
                {
                    WebAdminClient manager = new WebAdminClient();
                    manager.Initialize(servername);
                    try
                    {
                        IWebAdminServices client = manager.Open();
                        try
                        {
                            string nodetype          = client.GetNodeType(servername, false);
                            ADFSNodeInformation node = node = GetLocalNodeInformations(reg, servername);
                            node.NodeType = nodetype;
                            return(node);
                        }
                        finally
                        {
                            manager.Close(client);
                        }
                    }
                    catch (Exception e)
                    {
                        _log.WriteEntry(string.Format("Error on WebAdminService Service GetNodeInformations method : {0} / {1}.", servername, e.Message), EventLogEntryType.Error, 2010);
                        throw e;
                    }
                    finally
                    {
                        manager.UnInitialize();
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// InitSecurityFile method implementation
        /// </summary>
        protected void InitSecurityFile()
        {
            string         fqdn    = Dns.GetHostEntry("localhost").HostName;
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                MFAConfig         config = CFGReaderUtilities.ReadConfiguration();
                IWebAdminServices client = manager.Open();
                try
                {
                    SIDs.Clear();
                    SIDs.Assign(client.GetSIDsInformations(GetServers(config)));
                    SIDs.InternalUpdateDirectoryACLs(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + Path.DirectorySeparatorChar + "MFA");
                }
                catch (Exception ex)
                {
                    Log.WriteEntry(string.Format("Error on WebAdminService Service GetSIDsInformations method : {0} / {1}.", fqdn, ex.Message), EventLogEntryType.Error, 2010);
                    SIDs.Assign(new SIDsParametersRecord()
                    {
                        Loaded = false
                    });
                }
                finally
                {
                    manager.Close(client);
                }
            }
            catch (Exception e)
            {
                Log.WriteEntry(string.Format("Error on WebAdminService Service GetSIDsInformations method : {0} / {1}.", fqdn, e.Message), EventLogEntryType.Error, 2010);
            }
            finally
            {
                manager.UnInitialize();
            }
            return;
        }
コード例 #10
0
        /// <summary>
        /// GetAllComputerInformations method informations
        /// </summary>
        public static Dictionary <string, ADFSServerHost> GetAllComputerInformations()
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetAllComputersInformations());
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #11
0
        /// <summary>
        /// RemoveFirewallRules method implementation
        /// </summary>
        public static void RemoveFirewallRules()
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    client.RemoveFirewallRules();
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #12
0
        /// <summary>
        /// CreateADFSCertificate method implementation
        /// </summary>
        public static bool CreateADFSCertificate(MFAConfig config, string subject, bool issigning, int years)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.CreateADFSCertificate(GetServers(config), subject, issigning, years));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #13
0
        /// <summary>
        /// AddFirewallRules method implmentation
        /// </summary>
        public static void AddFirewallRules(string computers)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    client.AddFirewallRules(computers);
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #14
0
        /// <summary>
        /// ExistsMFASystemAESCngKeys method implementation
        /// </summary>
        public static bool ExistsMFASystemAESCngKeys()
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.ExistsMFASystemAESCngKeys());
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #15
0
        /// <summary>
        /// CreateRSACertificateForSQLEncryption method implementation
        /// </summary>
        public static string CreateRSACertificateForSQLEncryption(MFAConfig config, string subject, int years)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.CreateRSACertificateForSQLEncryption(GetServers(config), subject, years));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #16
0
        /// <summary>
        /// GetCertificate method implementation
        /// </summary>
        public static bool CertificateExists(string thumbprint, StoreLocation location)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.CertificateExists(thumbprint, (byte)location));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #17
0
        /// <summary>
        /// GetCompterInformations method informations
        /// </summary>
        public static ADFSNodeInformation GetNodeformations(RegistryVersion reg, string fqdn)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetNodeInformations(reg, fqdn, true));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #18
0
        /// <summary>
        /// UpdateCertificatesACL method implementation
        /// </summary>
        public static bool UpdateCertificatesACL(KeyMgtOptions options)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.UpdateCertificatesACL(options));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #19
0
        /// <summary>
        /// CleanOrphanedPrivateKeys method implementation
        /// </summary>
        public static int CleanOrphanedPrivateKeys(byte option, int delay)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.CleanOrphanedPrivateKeys(option, delay));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #20
0
        /// <summary>
        /// GetCompterInformations method informations
        /// </summary>
        public static ADFSServerHost GetComputerInformations(string fqdn)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetComputerInformations(fqdn));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #21
0
        /// <summary>
        /// UpdateDirectoriesACL method implementation
        /// </summary>
        public static void UpdateDirectoriesACL()
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    client.UpdateDirectoriesACL(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + Path.DirectorySeparatorChar + "MFA");
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
        /// <summary>
        /// SetBLOBPayloadCache method implmentation
        /// </summary>
        public static void SetBLOBPayloadCache(BLOBPayloadInformations infos)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    client.SetBLOBPayloadCache(infos);
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
        /// <summary>
        /// GetBLOBPayloadCache method implementation
        /// </summary>
        public static BLOBPayloadInformations GetBLOBPayloadCache()
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetBLOBPayloadCache());
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #24
0
        /// <summary>
        /// GetNodeType method informations
        /// </summary>
        public static string GetNodeType(string fqdn)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetNodeType(fqdn, true));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #25
0
        /// <summary>
        /// BroadcastNotification method implementation
        /// </summary>
        public static void BroadcastNotification(MFAConfig config, NotificationsKind kind, string message, bool local = true, bool dispatch = true)
        {
            WebAdminClient manager = new WebAdminClient();

            try
            {
                manager.Initialize();
                IWebAdminServices client = manager.Open();
                try
                {
                    client.BroadcastNotification(GetServers(config), CFGReaderUtilities.GetCryptedConfig(config), kind, message, local, dispatch);
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #26
0
        /// <summary>
        /// NewMFASystemAESCngKey method implementation
        /// </summary>
        public static bool NewMFASystemAESCngKey(MFAConfig config, bool deployonly = false, bool deleteonly = false)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.NewMFASystemAESCngKey(GetServers(config), deployonly, deleteonly));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
コード例 #27
0
        /// <summary>
        /// GetSIDsInformations method implmentation
        /// </summary>
        public static SIDsParametersRecord GetSIDsInformations(MFAConfig config)
        {
            string         fqdn    = Dns.GetHostEntry("localhost").HostName;
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.GetSIDsInformations(GetServers(config)));
                }
                catch (Exception ex)
                {
                    Log.WriteEntry(string.Format("Error on WebAdminService Service GetSIDsInformations method : {0} / {1}.", fqdn, ex.Message), EventLogEntryType.Error, 2010);
                    return(new SIDsParametersRecord()
                    {
                        Loaded = false
                    });
                }
                finally
                {
                    manager.Close(client);
                }
            }
            catch (Exception e)
            {
                Log.WriteEntry(string.Format("Error on WebAdminService Service GetSIDsInformations method : {0} / {1}.", fqdn, e.Message), EventLogEntryType.Error, 2010);
            }
            finally
            {
                manager.UnInitialize();
            }
            return(null);
        }
コード例 #28
0
        /// <summary>
        /// GetComputerInformations method implementation
        /// </summary>
        internal ADFSServerHost GetComputerInformations(string servername, bool dispatch = true)
        {
            string fqdn = Dns.GetHostEntry("localhost").HostName.ToLower();

            if (fqdn.ToLower().Equals(servername.ToLower()))
            {
                RegistryVersion     reg      = new RegistryVersion();
                string              nodetype = GetLocalNodeType();
                ADFSNodeInformation node     = GetLocalNodeInformations(reg, fqdn);
                node.NodeType = nodetype;
                return(new ADFSServerHost()
                {
                    FQDN = fqdn,
                    BehaviorLevel = node.BehaviorLevel,
                    HeartbeatTmeStamp = node.HeartbeatTmeStamp,
                    NodeType = node.NodeType,
                    CurrentVersion = reg.CurrentVersion,
                    CurrentBuild = reg.CurrentBuild,
                    InstallationType = reg.InstallationType,
                    ProductName = reg.ProductName,
                    CurrentMajorVersionNumber = reg.CurrentMajorVersionNumber,
                    CurrentMinorVersionNumber = reg.CurrentMinorVersionNumber
                });
            }
            else
            {
                if (dispatch)
                {
                    WebAdminClient manager = new WebAdminClient();
                    manager.Initialize(servername);
                    try
                    {
                        IWebAdminServices client = manager.Open();
                        try
                        {
                            return(client.GetComputerInformations(servername, false));
                        }
                        catch (CommunicationException nf)
                        {
                            _log.WriteEntry(nf.Message, EventLogEntryType.Error, 2010);
                            return(null);
                        }
                        finally
                        {
                            manager.Close(client);
                        }
                    }
                    catch (Exception e)
                    {
                        _log.WriteEntry(string.Format("Error on WebAdminService Service GetComputerInformations method : {0} / {1}.", servername, e.Message), EventLogEntryType.Error, 2010);
                        throw e;
                    }
                    finally
                    {
                        manager.UnInitialize();
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
        }
コード例 #29
0
        /// <summary>
        /// CreateRSACertificateForSQLEncryption method implementation
        /// </summary>
        internal string CreateRSACertificateForSQLEncryption(Dictionary <string, bool> servers, string subject, int years)
        {
            SIDs.Initialize();

            string thumbprint = null;

            try
            {
                string           strcert = string.Empty;
                X509Certificate2 cert    = null;
                try
                {
                    cert = Certs.CreateRSACertificateForSQLEncryption(subject, years, out strcert);
                    if (cert == null)
                    {
                        return(null);
                    }
                    else
                    {
                        thumbprint = cert.Thumbprint;
                    }
                }
                finally
                {
                    cert.Reset();
                }

                SIDs.internalUpdateCertificatesACLs(KeyMgtOptions.MFACerts);

                string        fqdn        = Dns.GetHostEntry("localhost").HostName;
                List <string> servernames = (from server in servers
                                             where (server.Key.ToLower() != fqdn.ToLower())
                                             select server.Key.ToLower()).ToList <string>();
                foreach (string srv in servernames)
                {
                    WebAdminClient manager = new WebAdminClient();
                    manager.Initialize(srv);
                    try
                    {
                        IWebAdminServices client = manager.Open();
                        try
                        {
                            client.PushCertificate(strcert);
                        }
                        finally
                        {
                            manager.Close(client);
                        }
                    }
                    catch (Exception e)
                    {
                        _log.WriteEntry(string.Format("Error on WebAdminService Service CreateRSACertificateForSQLEncryption method : {0} / {1}.", srv, e.Message), EventLogEntryType.Error, 2010);
                    }
                    finally
                    {
                        manager.UnInitialize();
                    }
                }
            }
            catch (Exception e)
            {
                _log.WriteEntry(string.Format("Error on WebAdminService Service CreateRSACertificateForSQLEncryption method : {0}.", e.Message), EventLogEntryType.Error, 2010);
                throw e;
            }
            return(thumbprint);
        }
コード例 #30
0
        /// <summary>
        /// BroadcastNotification method implementation
        /// </summary>
        public void BroadcastNotification(Dictionary <string, bool> servers, byte[] config, NotificationsKind kind, string message, bool local = true, bool dispatch = true, bool mustwrite = false)
        {
            try
            {
                if (local)
                {
                    switch (kind)
                    {
                    case NotificationsKind.ConfigurationReload:
                        if (!File.Exists(CFGUtilities.ConfigCacheFile))
                        {
                            mustwrite = true;
                        }
                        if (!File.Exists(SystemUtilities.SystemCacheFile))
                        {
                            mustwrite = true;
                        }
                        if (mustwrite)
                        {
                            WriteConfigurationToCache(config);
                        }
                        PushNotification(NotificationsKind.ConfigurationReload, message, null);
                        break;

                    case NotificationsKind.ConfigurationCreated:
                        WriteConfigurationToCache(config);
                        PushNotification(NotificationsKind.ConfigurationCreated, message, null);
                        break;

                    case NotificationsKind.ConfigurationDeleted:
                        DeleteConfigurationFromCache();
                        PushNotification(NotificationsKind.ConfigurationDeleted, message, null);
                        break;

                    case NotificationsKind.ServiceStatusInError:
                        PushNotification(NotificationsKind.ServiceStatusInError, message, "MGT");
                        break;

                    case NotificationsKind.ServiceStatusPending:
                        PushNotification(NotificationsKind.ServiceStatusPending, message, "MGT");
                        break;

                    case NotificationsKind.ServiceStatusRunning:
                        PushNotification(NotificationsKind.ServiceStatusRunning, message, "MGT");
                        break;

                    case NotificationsKind.ServiceStatusStopped:
                        PushNotification(NotificationsKind.ServiceStatusStopped, message, "MGT");
                        break;
                    }
                }
                if (dispatch)
                {
                    string        fqdn        = Dns.GetHostEntry("localhost").HostName;
                    List <string> servernames = (from server in servers
                                                 where (server.Key.ToLower() != fqdn.ToLower())
                                                 select server.Key.ToLower()).ToList <string>();

                    foreach (string srv in servernames)
                    {
                        WebAdminClient manager = new WebAdminClient();
                        manager.Initialize(srv);
                        try
                        {
                            IWebAdminServices client = manager.Open();
                            try
                            {
                                client.BroadcastNotification(servers, config, kind, message, true, false, true);
                            }
                            finally
                            {
                                manager.Close(client);
                            }
                        }
                        catch (Exception e)
                        {
                            _log.WriteEntry(string.Format("Error on WebAdminService Service BroadcastNotification method : {0} / {1}.", srv, e.Message), EventLogEntryType.Error, 2010);
                        }
                        finally
                        {
                            manager.UnInitialize();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _log.WriteEntry(string.Format("Error on WebAdminService Service BroadcastNotification method : {0}.", e.Message), EventLogEntryType.Error, 2010);
                throw e;
            }
        }