Beispiel #1
0
        private LocalizedString GetWhatIfMessage()
        {
            this.inputParams.CreateWhatIf = true;
            ExchangeCertificateRpcVersion exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version1;

            byte[] outputBlob = null;
            try
            {
                byte[] inBlob = this.inputParams.SerializeInputParameters(ExchangeCertificateRpcVersion.Version2);
                ExchangeCertificateRpcClient2 exchangeCertificateRpcClient = new ExchangeCertificateRpcClient2(this.serverObject.Name);
                outputBlob = exchangeCertificateRpcClient.CreateCertificate2(0, inBlob);
                exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version2;
            }
            catch (RpcException)
            {
                exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version1;
            }
            if (exchangeCertificateRpcVersion == ExchangeCertificateRpcVersion.Version1)
            {
                try
                {
                    byte[] inBlob2 = this.inputParams.SerializeInputParameters(exchangeCertificateRpcVersion);
                    ExchangeCertificateRpcClient exchangeCertificateRpcClient2 = new ExchangeCertificateRpcClient(this.serverObject.Name);
                    outputBlob = exchangeCertificateRpcClient2.CreateCertificate(0, inBlob2);
                }
                catch (RpcException e)
                {
                    ManageExchangeCertificate.WriteRpcError(e, this.serverObject.Name, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
            }
            ExchangeCertificateRpc exchangeCertificateRpc = new ExchangeCertificateRpc(exchangeCertificateRpcVersion, null, outputBlob);

            this.inputParams.CreateWhatIf = false;
            return(exchangeCertificateRpc.ReturnConfirmation);
        }
Beispiel #2
0
        protected override void InternalProcessRecord()
        {
            base.InternalProcessRecord();
            if (base.HasErrors)
            {
                return;
            }
            ExchangeCertificateRpcVersion exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version1;

            byte[] outputBlob = null;
            try
            {
                byte[] inBlob = this.inputParams.SerializeInputParameters(ExchangeCertificateRpcVersion.Version2);
                ExchangeCertificateRpcClient2 exchangeCertificateRpcClient = new ExchangeCertificateRpcClient2(this.serverObject.Name);
                outputBlob = exchangeCertificateRpcClient.CreateCertificate2(0, inBlob);
                exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version2;
            }
            catch (RpcException)
            {
                exchangeCertificateRpcVersion = ExchangeCertificateRpcVersion.Version1;
            }
            if (exchangeCertificateRpcVersion == ExchangeCertificateRpcVersion.Version1)
            {
                try
                {
                    byte[] inBlob2 = this.inputParams.SerializeInputParameters(ExchangeCertificateRpcVersion.Version1);
                    ExchangeCertificateRpcClient exchangeCertificateRpcClient2 = new ExchangeCertificateRpcClient(this.serverObject.Name);
                    outputBlob = exchangeCertificateRpcClient2.CreateCertificate(0, inBlob2);
                }
                catch (RpcException e)
                {
                    ManageExchangeCertificate.WriteRpcError(e, this.serverObject.Name, new Task.TaskErrorLoggingDelegate(base.WriteError));
                }
            }
            ExchangeCertificateRpc exchangeCertificateRpc = new ExchangeCertificateRpc(exchangeCertificateRpcVersion, null, outputBlob);

            ExchangeCertificateRpc.OutputTaskMessages(this.serverObject, exchangeCertificateRpc, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            if (this.GenerateRequest)
            {
                this.ProcessRequestResults(exchangeCertificateRpc.ReturnCert, exchangeCertificateRpc.ReturnCertRequest);
                return;
            }
            if (exchangeCertificateRpc.ReturnConfirmationList != null)
            {
                foreach (KeyValuePair <AllowedServices, LocalizedString> keyValuePair in exchangeCertificateRpc.ReturnConfirmationList)
                {
                    if (base.ShouldContinue(keyValuePair.Value))
                    {
                        ExchangeCertificateRpc exchangeCertificateRpc2 = new ExchangeCertificateRpc();
                        exchangeCertificateRpc2.EnableAllowConfirmation = false;
                        exchangeCertificateRpc2.EnableServices          = keyValuePair.Key;
                        AllowedServices key = keyValuePair.Key;
                        if (key == AllowedServices.SMTP)
                        {
                            exchangeCertificateRpc2.EnableUpdateAD = true;
                        }
                        exchangeCertificateRpc2.EnableByThumbprint = exchangeCertificateRpc.ReturnCert.Thumbprint;
                        try
                        {
                            byte[] inBlob3 = exchangeCertificateRpc2.SerializeInputParameters(exchangeCertificateRpcVersion);
                            if (exchangeCertificateRpcVersion == ExchangeCertificateRpcVersion.Version1)
                            {
                                ExchangeCertificateRpcClient exchangeCertificateRpcClient3 = new ExchangeCertificateRpcClient(this.serverObject.Name);
                                outputBlob = exchangeCertificateRpcClient3.EnableCertificate(0, inBlob3);
                            }
                            else
                            {
                                ExchangeCertificateRpcClient2 exchangeCertificateRpcClient4 = new ExchangeCertificateRpcClient2(this.serverObject.Name);
                                outputBlob = exchangeCertificateRpcClient4.EnableCertificate2(0, inBlob3);
                            }
                            exchangeCertificateRpc.ReturnCert.Services |= keyValuePair.Key;
                        }
                        catch (RpcException e2)
                        {
                            ManageExchangeCertificate.WriteRpcError(e2, this.serverObject.Name, new Task.TaskErrorLoggingDelegate(base.WriteError));
                        }
                        ExchangeCertificateRpc outputValues = new ExchangeCertificateRpc(exchangeCertificateRpcVersion, null, outputBlob);
                        ExchangeCertificateRpc.OutputTaskMessages(this.serverObject, outputValues, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
                    }
                }
            }
            exchangeCertificateRpc.ReturnCert.Identity = this.serverObject.Fqdn + "\\" + exchangeCertificateRpc.ReturnCert.Thumbprint;
            base.WriteObject(exchangeCertificateRpc.ReturnCert);
        }