Ejemplo n.º 1
0
        // Token: 0x060000E2 RID: 226 RVA: 0x00003F80 File Offset: 0x00002180
        public static string GetDiagnosticInfo(Exception ex, string diagnosticInfo)
        {
            AnchorUtil.ThrowOnNullArgument(ex, "ex");
            Exception innerException = ex.InnerException;
            int       num            = 0;

            while (num < 10 && innerException != null)
            {
                MapiPermanentException ex2 = innerException as MapiPermanentException;
                MapiRetryableException ex3 = innerException as MapiRetryableException;
                string text = innerException.Message;
                if (ex2 != null)
                {
                    text = ex2.DiagCtx.ToCompactString();
                }
                else if (ex3 != null)
                {
                    text = ex3.DiagCtx.ToCompactString();
                }
                if (!string.IsNullOrEmpty(text))
                {
                    if (diagnosticInfo == null)
                    {
                        diagnosticInfo = string.Format(CultureInfo.InvariantCulture, "InnerException:{0}:{1}", new object[]
                        {
                            innerException.GetType().Name,
                            text
                        });
                    }
                    else
                    {
                        diagnosticInfo = string.Format(CultureInfo.InvariantCulture, "{0} InnerException:{1}:{2}", new object[]
                        {
                            diagnosticInfo,
                            innerException.GetType().Name,
                            text
                        });
                    }
                }
                num++;
                innerException = innerException.InnerException;
            }
            string value = string.Empty;
            MigrationPermanentException ex4 = ex as MigrationPermanentException;
            MigrationTransientException ex5 = ex as MigrationTransientException;

            if (ex4 != null)
            {
                value = ex4.InternalError + ". ";
            }
            else if (ex5 != null)
            {
                value = ex5.InternalError + ". ";
            }
            StringBuilder stringBuilder = new StringBuilder(value);

            stringBuilder.Append(diagnosticInfo);
            stringBuilder.Append(ex.ToString());
            return(AnchorLogger.SanitizeDiagnosticInfo(stringBuilder.ToString()));
        }
Ejemplo n.º 2
0
 private AnchorRunspaceProxy(AnchorContext context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity runspaceFactory)
 {
     AnchorUtil.ThrowOnNullArgument(context, "context");
     AnchorUtil.ThrowOnNullArgument(runspaceFactory, "runspaceFactory");
     this.Context       = context;
     this.runspaceProxy = new RunspaceProxy(new RunspaceMediator(runspaceFactory, new EmptyRunspaceCache()));
 }
 // Token: 0x06000029 RID: 41 RVA: 0x0000227C File Offset: 0x0000047C
 public AnchorADProvider(AnchorContext context, OrganizationId organizationId, string preferredDomainController = null)
 {
     AnchorUtil.ThrowOnNullArgument(organizationId, "organizationId");
     this.Context                   = context;
     this.OrganizationId            = organizationId;
     this.preferredDomainController = preferredDomainController;
     this.RecipientSession          = this.CreateRecipientSession();
     this.lazyConfigurationSession  = new Lazy <ITopologyConfigurationSession>(new Func <ITopologyConfigurationSession>(AnchorADProvider.CreateTopologyConfigurationSession));
 }
        // Token: 0x0600003F RID: 63 RVA: 0x000027AC File Offset: 0x000009AC
        public void EnsureLocalMailbox(ADUser user, bool forceRefresh)
        {
            AnchorUtil.ThrowOnNullArgument(user, "user");
            string mailboxServerFqdn = this.GetMailboxServerFqdn(user, forceRefresh);

            if (!string.Equals(mailboxServerFqdn, LocalServer.GetServer().Fqdn, StringComparison.OrdinalIgnoreCase))
            {
                throw new AnchorMailboxNotFoundOnServerException(mailboxServerFqdn, LocalServer.GetServer().Fqdn, user.DistinguishedName);
            }
        }
        // Token: 0x06000035 RID: 53 RVA: 0x000023D4 File Offset: 0x000005D4
        public ADRecipient GetADRecipientByObjectId(ADObjectId objectId)
        {
            AnchorUtil.ThrowOnNullArgument(objectId, "objectId");
            ADRecipient recipient = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                recipient = this.RecipientSession.Read(objectId);
            }, false);
            return(recipient);
        }
        // Token: 0x06000039 RID: 57 RVA: 0x00002498 File Offset: 0x00000698
        public void AddCapability(ADObjectId objectId, OrganizationCapability capability)
        {
            AnchorUtil.ThrowOnNullArgument(objectId, "objectId");
            ADUser user = this.GetAnchorADUser(objectId);

            this.DoAdCallAndTranslateExceptions(delegate
            {
                user.PersistedCapabilities.Add((Capability)capability);
                this.RecipientSession.Save(user);
            }, true);
        }
Ejemplo n.º 7
0
        public static AnchorRunspaceProxy CreateRunspaceForDelegatedTenantAdmin(AnchorContext context, DelegatedPrincipal delegatedTenantAdmin)
        {
            AnchorUtil.ThrowOnNullArgument(delegatedTenantAdmin, "delegatedTenantAdmin");
            context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating delegated runspace proxy for user {0}", new object[]
            {
                delegatedTenantAdmin
            });
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, null, ExchangeRunspaceConfigurationSettings.SerializationLevel.None);

            return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, delegatedTenantAdmin.ToString(), delegatedTenantAdmin.Identity, configSettings)));
        }
        // Token: 0x06000043 RID: 67 RVA: 0x00002898 File Offset: 0x00000A98
        private ADUser GetAnchorADUser(ADObjectId objectId)
        {
            AnchorUtil.ThrowOnNullArgument(objectId, "objectId");
            ADUser aduser = this.GetADRecipientByObjectId(objectId) as ADUser;

            if (aduser == null)
            {
                throw new AnchorMailboxNotFoundException();
            }
            return(aduser);
        }
Ejemplo n.º 9
0
        protected virtual AnchorJobProcessorResult ProcessEntry(CacheEntryBase cacheEntry)
        {
            AnchorUtil.ThrowOnNullArgument(cacheEntry, "cacheEntry");
            AnchorJobProcessorResult anchorJobProcessorResult = this.ShouldProcessEntry(cacheEntry);

            if (anchorJobProcessorResult != AnchorJobProcessorResult.Working)
            {
                return(anchorJobProcessorResult);
            }
            return(AnchorJobProcessorResult.Waiting);
        }
Ejemplo n.º 10
0
        public static AnchorRunspaceProxy CreateRunspaceForTenantAdmin(AnchorContext context, ADObjectId ownerId, ADUser tenantAdmin)
        {
            AnchorUtil.ThrowOnNullArgument(tenantAdmin, "tenantAdmin");
            AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId");
            context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating runspace proxy for user {0}", new object[]
            {
                tenantAdmin.Name
            });
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, null, ExchangeRunspaceConfigurationSettings.SerializationLevel.None);

            return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, ownerId.ToString(), new GenericSidIdentity(tenantAdmin.Name, string.Empty, tenantAdmin.Sid), configSettings)));
        }
Ejemplo n.º 11
0
        public static AnchorRunspaceProxy CreateRunspaceForDelegatedPartner(AnchorContext context, DelegatedPrincipal delegatedPartnerAdmin, string tenantOrganization)
        {
            AnchorUtil.ThrowOnNullArgument(delegatedPartnerAdmin, "delegatedTenantAdmin");
            AnchorUtil.ThrowOnNullOrEmptyArgument(tenantOrganization, "tenantOrganization");
            context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating delegated partner runspace proxy for user {0}", new object[]
            {
                delegatedPartnerAdmin
            });
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, tenantOrganization, ExchangeRunspaceConfigurationSettings.GetDefaultInstance().CurrentSerializationLevel);

            return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, delegatedPartnerAdmin.ToString(), delegatedPartnerAdmin.Identity, configSettings)));
        }
 // Token: 0x06000042 RID: 66 RVA: 0x00002848 File Offset: 0x00000A48
 private string GetMailboxServerFqdn(ExchangePrincipal mailboxOwner, bool forceRefresh)
 {
     AnchorUtil.ThrowOnNullArgument(mailboxOwner, "mailboxOwner");
     if (mailboxOwner.MailboxInfo.Location == null)
     {
         forceRefresh = true;
     }
     if (!forceRefresh)
     {
         return(mailboxOwner.MailboxInfo.Location.ServerFqdn);
     }
     return(this.GetDatabaseServerFqdn(mailboxOwner.MailboxInfo.GetDatabaseGuid(), true));
 }
Ejemplo n.º 13
0
 internal void Remove(CacheEntryBase cacheEntry)
 {
     AnchorUtil.ThrowOnNullArgument(cacheEntry, "cacheEntry");
     this.Context.Logger.Log(MigrationEventType.Warning, "Deactivating CacheEntry {0} ...", new object[]
     {
         cacheEntry
     });
     cacheEntry.Deactivate();
     lock (this.sharedDataLock)
     {
         this.cacheEntries.Remove(cacheEntry.ObjectId);
     }
 }
Ejemplo n.º 14
0
 // Token: 0x060000ED RID: 237 RVA: 0x00004264 File Offset: 0x00002464
 public void LogError(Exception exception, string formatString, params object[] formatArgs)
 {
     AnchorUtil.ThrowOnNullArgument(formatArgs, "formatArgs");
     AnchorUtil.ThrowOnNullArgument(formatString, "formatString");
     if (formatArgs.Length == 0)
     {
         this.Log(MigrationEventType.Error, exception, "{0}", new object[]
         {
             formatString
         });
         return;
     }
     this.Log(MigrationEventType.Error, exception, formatString, formatArgs);
 }
Ejemplo n.º 15
0
 // Token: 0x060000F7 RID: 247 RVA: 0x0000439C File Offset: 0x0000259C
 internal static void LogEvent(ExEventLog eventLogger, ExEventLog.EventTuple eventId, bool includeAnchorContext, params string[] messageArgs)
 {
     AnchorUtil.ThrowOnNullArgument(eventLogger, "eventLogger");
     AnchorUtil.ThrowOnNullArgument(messageArgs, "messageArgs");
     if (messageArgs == null || messageArgs.Length <= 0)
     {
         return;
     }
     if (includeAnchorContext)
     {
         messageArgs[0] = AnchorLogContext.Current.ToString() + ":" + messageArgs[0];
     }
     eventLogger.LogEvent(eventId, AnchorLogContext.Current.Source, messageArgs);
 }
Ejemplo n.º 16
0
        // Token: 0x060000E1 RID: 225 RVA: 0x00003ECC File Offset: 0x000020CC
        public static string PropertyBagToString(PropertyBag bag)
        {
            AnchorUtil.ThrowOnNullArgument(bag, "bag");
            StringBuilder stringBuilder = new StringBuilder(bag.Count * 128);

            foreach (object obj in bag.Keys)
            {
                PropertyDefinition propertyDefinition = obj as PropertyDefinition;
                if (propertyDefinition != null)
                {
                    stringBuilder.Append(string.Format(CultureInfo.InvariantCulture, "[{0}:{1}]", new object[]
                    {
                        propertyDefinition.Name,
                        bag[propertyDefinition]
                    }));
                }
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 17
0
        internal bool TryUpdate(CacheEntryBase cacheEntry, bool wakeCache)
        {
            AnchorUtil.ThrowOnNullArgument(cacheEntry, "cacheEntry");
            bool flag = cacheEntry.Validate();

            if (this.Contains(cacheEntry.ObjectId))
            {
                if (!flag)
                {
                    lock (this.sharedDataLock)
                    {
                        this.Context.Logger.Log(MigrationEventType.Warning, "Removing CacheEntry {0} because it's invalid ...", new object[]
                        {
                            cacheEntry
                        });
                        this.cacheEntries.Remove(cacheEntry.ObjectId);
                        goto IL_9E;
                    }
                }
                this.Context.Logger.Log(MigrationEventType.Verbose, "CacheEntry {0} already exists in cache, skipping add", new object[]
                {
                    cacheEntry
                });
                return(true);
            }
IL_9E:
            if (!flag)
            {
                return(false);
            }
            lock (this.sharedDataLock)
            {
                this.cacheEntries[cacheEntry.ObjectId] = cacheEntry;
            }
            if (wakeCache && this.Context.Config.GetConfig <bool>("ShouldWakeOnCacheUpdate"))
            {
                this.Context.Logger.Log(MigrationEventType.Information, "triggering cache update", new object[0]);
                this.cacheUpdated.Set();
            }
            return(true);
        }
Ejemplo n.º 18
0
 public static AnchorRunspaceProxy CreateRunspaceForDatacenterAdmin(AnchorContext context, string ownerId)
 {
     AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId");
     context.Logger.Log(MigrationEventType.Verbose, "Creating runspace proxy for datacenter admin", new object[0]);
     return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateUnrestrictedFactory(ownerId)));
 }
Ejemplo n.º 19
0
 public static AnchorRunspaceProxy CreateRunspaceForDatacenterAdmin(AnchorContext context, ADObjectId ownerId)
 {
     AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId");
     return(AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(context, ownerId.ToString()));
 }
 // Token: 0x060000C5 RID: 197 RVA: 0x00003B33 File Offset: 0x00001D33
 public void ClearSummarizable(ISummarizable summarizable)
 {
     AnchorUtil.ThrowOnNullArgument(summarizable, "summarizable");
     this.summarizables.Remove(summarizable.SummaryName);
     this.isDirty = true;
 }
Ejemplo n.º 21
0
        // Token: 0x0600015E RID: 350 RVA: 0x00005644 File Offset: 0x00003844
        internal override bool Process(JobCache data)
        {
            AnchorUtil.ThrowOnNullArgument(data, "data");
            if (base.LastRunTime == null)
            {
                TimeSpan config = base.Context.Config.GetConfig <TimeSpan>("ScannerInitialTimeDelay");
                if (!config.Equals(TimeSpan.Zero))
                {
                    base.Context.Logger.Log(MigrationEventType.Information, "Sleeping initial delay of {0} on start", new object[]
                    {
                        config
                    });
                    base.StopEvent.WaitOne(config, false);
                }
            }
            this.nextProcessTime = ExDateTime.UtcNow.Add(base.Context.Config.GetConfig <TimeSpan>("ScannerTimeDelay"));
            if (base.Context.Config.GetConfig <bool>("ScannerClearCacheOnRefresh"))
            {
                data.Clear();
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;
            HashSet <ADObjectId> hashSet = new HashSet <ADObjectId>();

            foreach (ADUser aduser in this.GetLocalMailboxUsers())
            {
                hashSet.Add(aduser.ObjectId);
                bool flag = data.Contains(aduser.ObjectId);
                if (data.TryAdd(aduser, false))
                {
                    if (flag)
                    {
                        num2++;
                    }
                    else
                    {
                        num++;
                    }
                }
                else if (flag)
                {
                    num3++;
                }
            }
            foreach (CacheEntryBase cacheEntryBase in data.Get())
            {
                if (!hashSet.Contains(cacheEntryBase.ObjectId))
                {
                    if (data.TryUpdate(cacheEntryBase, false))
                    {
                        num2++;
                    }
                    else
                    {
                        num3++;
                    }
                }
            }
            this.diagnosticMessage = string.Format(" Modified {0}, Added {1}, removed {2} cache entries", num2, num, num3);
            if (num > 0 || num3 > 0)
            {
                base.Context.Logger.Log(MigrationEventType.Information, this.diagnosticMessage, new object[0]);
            }
            else
            {
                base.Context.Logger.Log(MigrationEventType.Verbose, this.diagnosticMessage, new object[0]);
            }
            return(false);
        }
Ejemplo n.º 22
0
 internal bool TryAdd(ADUser user, bool wakeCache)
 {
     AnchorUtil.ThrowOnNullArgument(user, "user");
     return(this.TryUpdate(this.Context.CreateCacheEntry(user), wakeCache));
 }
Ejemplo n.º 23
0
        internal override bool Process(JobCache data)
        {
            AnchorUtil.ThrowOnNullArgument(data, "data");
            bool result = false;
            int  num    = 0;
            int  num2   = 0;

            foreach (CacheEntryBase cacheEntryBase in data.Get())
            {
                if (base.StopEvent.WaitOne(0, false))
                {
                    break;
                }
                int config = base.Context.Config.GetConfig <int>("MaximumCacheEntrySchedulerRun");
                if (config >= 0 && num++ >= config)
                {
                    base.Context.Logger.Log(MigrationEventType.Error, "Skipping run of {0} because too many cache entries {1} expected {2}", new object[]
                    {
                        cacheEntryBase,
                        num,
                        config
                    });
                }
                else
                {
                    AnchorLogContext.Current.OrganizationId = cacheEntryBase.OrganizationId;
                    try
                    {
                        AnchorJobProcessorResult anchorJobProcessorResult = AnchorJobProcessorResult.Working;
                        try
                        {
                            cacheEntryBase.ServiceException = null;
                            anchorJobProcessorResult        = this.ProcessEntry(cacheEntryBase);
                            num2 = 0;
                        }
                        catch (TransientException ex)
                        {
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered a transient error {1}", new object[]
                            {
                                cacheEntryBase,
                                ex
                            });
                            anchorJobProcessorResult = AnchorJobProcessorResult.Waiting;
                            num2 = 0;
                        }
                        catch (StoragePermanentException ex2)
                        {
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered a permanent error {1}", new object[]
                            {
                                cacheEntryBase,
                                ex2
                            });
                            anchorJobProcessorResult = AnchorJobProcessorResult.Waiting;
                            num2 = 0;
                        }
                        catch (MigrationPermanentException ex3)
                        {
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered a permanent error {1}", new object[]
                            {
                                cacheEntryBase,
                                ex3
                            });
                            anchorJobProcessorResult = AnchorJobProcessorResult.Waiting;
                            num2 = 0;
                        }
                        catch (Exception ex4)
                        {
                            if (base.Context.Config.GetConfig <bool>("UseWatson"))
                            {
                                ExWatson.SendReport(ex4);
                            }
                            cacheEntryBase.ServiceException = ex4;
                            anchorJobProcessorResult        = AnchorJobProcessorResult.Waiting;
                            num2++;
                            base.Context.Logger.Log(MigrationEventType.Error, "entry {0} encountered an unhandled error {1}, poison count {2} triggering alert notification", new object[]
                            {
                                cacheEntryBase,
                                ex4,
                                num2
                            });
                            if (!AnchorIssueCache.TrySendEventNotification(base.Context, base.Context.Config.GetConfig <string>("CacheEntryPoisonNotificationReason"), cacheEntryBase.ToString(), ResultSeverityLevel.Error))
                            {
                                throw;
                            }
                            if (num2 >= base.Context.Config.GetConfig <int>("CacheEntryPoisonThreshold"))
                            {
                                throw;
                            }
                        }
                        switch (anchorJobProcessorResult)
                        {
                        case AnchorJobProcessorResult.Working:
                            result = true;
                            continue;

                        case AnchorJobProcessorResult.Waiting:
                            continue;

                        case AnchorJobProcessorResult.Failed:
                            base.Context.Logger.Log(MigrationEventType.Error, "marking job cache entry failed.. {0}", new object[]
                            {
                                cacheEntryBase
                            });
                            data.Remove(cacheEntryBase);
                            continue;

                        case AnchorJobProcessorResult.Deleted:
                            base.Context.Logger.Log(MigrationEventType.Information, "Removing deleted job cache entry {0}", new object[]
                            {
                                cacheEntryBase
                            });
                            data.Remove(cacheEntryBase);
                            result = true;
                            continue;
                        }
                        throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid AnchorJobProcessorResult {0}", new object[]
                        {
                            anchorJobProcessorResult
                        }));
                    }
                    finally
                    {
                        AnchorLogContext.Current.OrganizationId = null;
                    }
                }
            }
            return(result);
        }
 // Token: 0x060000C4 RID: 196 RVA: 0x00003B0D File Offset: 0x00001D0D
 public void SetSummarizable(ISummarizable summarizable)
 {
     AnchorUtil.ThrowOnNullArgument(summarizable, "summarizable");
     this.summarizables[summarizable.SummaryName] = summarizable;
     this.isDirty = true;
 }