Esempio n. 1
0
        private void CreateNotification(IEnumerable <ExchangeCertificate> certificates, bool isExpired)
        {
            ADRecipientOrAddress       owner = null;
            MicrosoftExchangeRecipient microsoftExchangeRecipient = this.adSession.FindMicrosoftExchangeRecipient();

            if (microsoftExchangeRecipient == null)
            {
                this.EventLog.LogEvent(CertificateNotificationEventLogConstants.Tuple_MicrosoftExchangeRecipientNotFoundException, string.Empty, new object[]
                {
                    string.Empty
                });
            }
            else
            {
                owner = new ADRecipientOrAddress(new Participant(microsoftExchangeRecipient));
            }
            foreach (ExchangeCertificate exchangeCertificate in certificates)
            {
                KeyValuePair <string, LocalizedString>[] extendedAttributes = new KeyValuePair <string, LocalizedString>[]
                {
                    new KeyValuePair <string, LocalizedString>("ServerName", new LocalizedString(this.serverObj.Name)),
                    new KeyValuePair <string, LocalizedString>("ServerFqdn", new LocalizedString(this.serverObj.Fqdn)),
                    new KeyValuePair <string, LocalizedString>("ThumbPrint", new LocalizedString(exchangeCertificate.Thumbprint)),
                    new KeyValuePair <string, LocalizedString>("FriendlyName", new LocalizedString(exchangeCertificate.FriendlyName)),
                    new KeyValuePair <string, LocalizedString>("ExpireDate", new LocalizedString(exchangeCertificate.NotAfter.ToFileTimeUtc().ToString()))
                };
                string id = this.serverObj.Fqdn + "\\" + exchangeCertificate.Thumbprint;
                AsyncOperationNotificationDataProvider.CreateNotification(this.orgId, id, AsyncOperationType.CertExpiry, isExpired ? AsyncOperationStatus.CertExpired : AsyncOperationStatus.CertExpiring, new LocalizedString(exchangeCertificate.FriendlyName), owner, extendedAttributes, false);
                AsyncOperationNotificationDataProvider.SendNotificationEmail(this.orgId, id, false, null, false);
            }
        }