コード例 #1
0
 // Token: 0x0600016E RID: 366 RVA: 0x00009AC4 File Offset: 0x00007CC4
 internal void Start(MailboxSession mailboxSession)
 {
     if (DiscoveryHoldSynchronizer.IsOnPremDiscoveryArbitrationMailbox(mailboxSession))
     {
         if (this.cancellationTokenSource == null)
         {
             this.cancellationTokenSource = new CancellationTokenSource();
         }
         if (this.synchronizeTask != null && this.synchronizeTask.IsCompleted)
         {
             this.synchronizeTask.Dispose();
             this.synchronizeTask = null;
         }
         if (this.synchronizeTask == null)
         {
             this.synchronizeTask = new Task(new Action <object>(this.Synchronize), mailboxSession.MailboxOwner.ObjectId.ObjectGuid, this.cancellationTokenSource.Token);
             this.synchronizeTask.ContinueWith(delegate(Task task)
             {
                 if (task.IsFaulted && task.Exception != null && task.Exception.InnerException != null)
                 {
                     if (!(task.Exception.InnerException is LocalizedException) && GrayException.IsGrayException(task.Exception.InnerException))
                     {
                         ExWatson.SendReport(task.Exception.InnerException, ReportOptions.None, null);
                     }
                     SearchEventLogger.Instance.LogFailedToSyncDiscoveryHoldToExchangeOnlineEvent(task.Exception.InnerException);
                 }
             }, this.cancellationTokenSource.Token);
             this.synchronizeTask.Start();
         }
     }
 }
コード例 #2
0
 // Token: 0x06000170 RID: 368 RVA: 0x00009C70 File Offset: 0x00007E70
 internal void Synchronize(object argument)
 {
     try
     {
         ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Combine(ServicePointManager.ServerCertificateValidationCallback, new RemoteCertificateValidationCallback(CertificateValidation.CertificateErrorHandler));
         Guid b = (Guid)argument;
         SearchEventLogger.Instance.LogSyncDiscoveryHoldToExchangeOnlineStartEvent(b.ToString());
         DiscoverySearchDataProvider discoverySearchDataProvider = new DiscoverySearchDataProvider(OrganizationId.ForestWideOrgId);
         if (discoverySearchDataProvider.ObjectGuid == b)
         {
             Dictionary <string, MailboxDiscoverySearch> dictionary = new Dictionary <string, MailboxDiscoverySearch>();
             SmtpAddress discoveryHolds = DiscoveryHoldSynchronizer.GetDiscoveryHolds(discoverySearchDataProvider, dictionary);
             SearchEventLogger.Instance.LogSyncDiscoveryHoldToExchangeOnlineDetailsEvent(dictionary.Count, discoveryHolds.ToString());
             if (discoveryHolds != SmtpAddress.Empty)
             {
                 Uri    uri = null;
                 string str = string.Empty;
                 EndPointDiscoveryInfo endPointDiscoveryInfo;
                 bool flag = RemoteDiscoveryEndPoint.TryGetDiscoveryEndPoint(OrganizationId.ForestWideOrgId, discoveryHolds.Domain, null, null, null, out uri, out endPointDiscoveryInfo);
                 if (endPointDiscoveryInfo != null && endPointDiscoveryInfo.Status != EndPointDiscoveryInfo.DiscoveryStatus.Success)
                 {
                     str = endPointDiscoveryInfo.Message;
                     DiscoveryHoldSynchronizer.Tracer.TraceDebug <EndPointDiscoveryInfo.DiscoveryStatus, string>((long)this.GetHashCode(), "Getting autodiscover url encountered problem with status {0}. {1}", endPointDiscoveryInfo.Status, endPointDiscoveryInfo.Message);
                 }
                 if (flag && uri != null)
                 {
                     uri = EwsWsSecurityUrl.FixForAnonymous(uri);
                     AutodiscoverService autodiscoverService = new AutodiscoverService(uri, 4);
                     OAuthCredentials    credentials         = new OAuthCredentials(OAuthCredentials.GetOAuthCredentialsForAppToken(OrganizationId.ForestWideOrgId, discoveryHolds.Domain));
                     autodiscoverService.Credentials = credentials;
                     GetUserSettingsResponse userSettings = autodiscoverService.GetUserSettings(discoveryHolds.ToString(), new UserSettingName[]
                     {
                         58
                     });
                     if (userSettings != null && userSettings.ErrorCode == null && userSettings.Settings != null && userSettings.Settings.ContainsKey(58))
                     {
                         string          uriString       = userSettings.Settings[58].ToString();
                         ExchangeService exchangeService = new ExchangeService(4);
                         exchangeService.Credentials     = credentials;
                         exchangeService.Url             = new Uri(uriString);
                         exchangeService.ManagementRoles = new ManagementRoles(null, "LegalHoldApplication");
                         GetDiscoverySearchConfigurationResponse discoverySearchConfiguration = exchangeService.GetDiscoverySearchConfiguration(null, false, true);
                         if (discoverySearchConfiguration.Result == 2)
                         {
                             SearchEventLogger.Instance.LogFailedToSyncDiscoveryHoldToExchangeOnlineEvent(string.Format("ErrorCode={0}&ErrorMessage={1}", discoverySearchConfiguration.ErrorCode, discoverySearchConfiguration.ErrorMessage));
                             goto IL_402;
                         }
                         foreach (DiscoverySearchConfiguration discoverySearchConfiguration2 in discoverySearchConfiguration.DiscoverySearchConfigurations)
                         {
                             MailboxDiscoverySearch mailboxDiscoverySearch = null;
                             if (dictionary.TryGetValue(discoverySearchConfiguration2.InPlaceHoldIdentity, out mailboxDiscoverySearch))
                             {
                                 if (mailboxDiscoverySearch.Name != discoverySearchConfiguration2.SearchId)
                                 {
                                     if (DiscoveryHoldSynchronizer.CallSetHoldOnMailboxes(exchangeService, discoverySearchConfiguration2.SearchId, 2, discoverySearchConfiguration2.SearchQuery, discoverySearchConfiguration2.InPlaceHoldIdentity, null))
                                     {
                                         DiscoveryHoldSynchronizer.CallSetHoldOnMailboxes(exchangeService, mailboxDiscoverySearch.Name, 0, mailboxDiscoverySearch.CalculatedQuery, mailboxDiscoverySearch.InPlaceHoldIdentity, mailboxDiscoverySearch.ItemHoldPeriod.ToString());
                                     }
                                 }
                                 else
                                 {
                                     DiscoveryHoldSynchronizer.CallSetHoldOnMailboxes(exchangeService, mailboxDiscoverySearch.Name, 1, mailboxDiscoverySearch.CalculatedQuery, mailboxDiscoverySearch.InPlaceHoldIdentity, mailboxDiscoverySearch.ItemHoldPeriod.ToString());
                                 }
                                 dictionary.Remove(discoverySearchConfiguration2.InPlaceHoldIdentity);
                             }
                             else if (discoverySearchConfiguration2.ManagedByOrganization == "b5d6efcd-1aee-42b9-b168-6fef285fe613")
                             {
                                 DiscoveryHoldSynchronizer.CallSetHoldOnMailboxes(exchangeService, discoverySearchConfiguration2.SearchId, 2, discoverySearchConfiguration2.SearchQuery, discoverySearchConfiguration2.InPlaceHoldIdentity, null);
                             }
                         }
                         using (Dictionary <string, MailboxDiscoverySearch> .ValueCollection.Enumerator enumerator = dictionary.Values.GetEnumerator())
                         {
                             while (enumerator.MoveNext())
                             {
                                 MailboxDiscoverySearch mailboxDiscoverySearch2 = enumerator.Current;
                                 DiscoveryHoldSynchronizer.CallSetHoldOnMailboxes(exchangeService, mailboxDiscoverySearch2.Name, 0, mailboxDiscoverySearch2.CalculatedQuery, mailboxDiscoverySearch2.InPlaceHoldIdentity, mailboxDiscoverySearch2.ItemHoldPeriod.ToString());
                             }
                             goto IL_402;
                         }
                     }
                     string str2 = string.Empty;
                     if (userSettings != null && userSettings.ErrorCode != null)
                     {
                         str2 = string.Format("ErrorCode={0}&ErrorMessage={1}", userSettings.ErrorCode, userSettings.ErrorMessage);
                     }
                     SearchEventLogger.Instance.LogFailedToSyncDiscoveryHoldToExchangeOnlineEvent("Failed to get autodiscover settings. " + str2);
                 }
                 else
                 {
                     SearchEventLogger.Instance.LogFailedToSyncDiscoveryHoldToExchangeOnlineEvent("Failed to get autodiscover URL. " + str);
                 }
             }
         }
         IL_402 :;
     }
     finally
     {
         ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Remove(ServicePointManager.ServerCertificateValidationCallback, new RemoteCertificateValidationCallback(CertificateValidation.CertificateErrorHandler));
     }
 }