/// <summary>
        /// Gets the availability and accessibility of ADCS Certification Authority request RPC/DCOM interface.
        /// </summary>
        /// <exception cref="UninitializedObjectException">The <see cref="CertificateAuthority"/> object is not
        /// initialized through a class constructor.</exception>
        /// <returns>
        /// <strong>True</strong> if request interfaces are available and caller has permissions to access it, otherwise <strong>False</strong>.
        /// </returns>
        public Boolean PingRequest()
        {
            if (String.IsNullOrEmpty(ComputerName))
            {
                throw new UninitializedObjectException();
            }

            try {
                var propReader = new CertPropReaderD(ConfigString, false);
                propReader.GetProductVersionProperty();
                return(true);
            } catch {
                return(false);
            }
        }
示例#2
0
        void m_initialize(CertificateAuthority certificateAuthority)
        {
            if (!certificateAuthority.IsEnterprise)
            {
                throw new PlatformNotSupportedException();
            }

            version      = certificateAuthority.Version;
            sku          = certificateAuthority.Sku;
            configString = certificateAuthority.ConfigString;

            ICertPropReaderD propReader;

            if (certificateAuthority.PingRequest())
            {
                propReader = new CertPropReaderD(configString, false);
            }
            else if (certificateAuthority.PingAdmin())
            {
                propReader = new CertPropReaderD(configString, true);
            }
            else
            {
                var e = new ServerUnavailableException(certificateAuthority.DisplayName);
                e.Data.Add(nameof(e.Source), OfflineSource.DCOM);
                throw e;
            }

            Name         = certificateAuthority.Name;
            DisplayName  = certificateAuthority.DisplayName;
            ComputerName = certificateAuthority.ComputerName;

            String[,] templates = propReader.GetCaTemplates();
            for (Int32 i = 0; i <= templates.GetUpperBound(0); i++)
            {
                _templates.Add(CertificateTemplate.FromCommonName(templates[i, 0]));
            }
        }