Ejemplo n.º 1
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);
     }
 }
        // Token: 0x0600003A RID: 58 RVA: 0x0000251C File Offset: 0x0000071C
        public void RemoveCapability(ADObjectId objectId, OrganizationCapability capability)
        {
            AnchorUtil.ThrowOnNullArgument(objectId, "objectId");
            ADUser user = this.GetAnchorADUser(objectId);

            this.DoAdCallAndTranslateExceptions(delegate
            {
                if (user.PersistedCapabilities.Remove((Capability)capability))
                {
                    this.RecipientSession.Save(user);
                }
            }, true);
        }
 // 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));
 }
        // Token: 0x06000109 RID: 265 RVA: 0x000046CC File Offset: 0x000028CC
        public static AnchorRunspaceProxy CreateRunspaceForPartner(AnchorContext context, ADObjectId ownerId, ADUser tenantAdmin, string tenantOrganization)
        {
            AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId");
            AnchorUtil.ThrowOnNullArgument(tenantAdmin, "tenantAdmin");
            AnchorUtil.ThrowOnNullOrEmptyArgument(tenantOrganization, "tenantOrganization");
            context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating partner runspace proxy for user {0}", new object[]
            {
                tenantAdmin.Name
            });
            ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, tenantOrganization, ExchangeRunspaceConfigurationSettings.GetDefaultInstance().CurrentSerializationLevel);

            return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, ownerId.ToString(), new GenericSidIdentity(tenantAdmin.Name, string.Empty, tenantAdmin.Sid), configSettings)));
        }
Ejemplo n.º 5
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.º 6
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.º 7
0
 // Token: 0x060000E3 RID: 227 RVA: 0x000040DC File Offset: 0x000022DC
 public static string SanitizeDiagnosticInfo(string diagnosticInfo)
 {
     AnchorUtil.ThrowOnNullOrEmptyArgument(diagnosticInfo, "diagnosticInfo");
     diagnosticInfo = diagnosticInfo.Replace("  ", " ");
     diagnosticInfo = diagnosticInfo.Replace("\n", " ");
     diagnosticInfo = diagnosticInfo.Replace("\r", " ");
     diagnosticInfo = diagnosticInfo.Replace("\t", " ");
     diagnosticInfo = diagnosticInfo.Replace("{", "[");
     diagnosticInfo = diagnosticInfo.Replace("}", "]");
     if (diagnosticInfo.Length > 16384)
     {
         return(diagnosticInfo.Substring(0, 16381) + "...");
     }
     return(diagnosticInfo);
 }
Ejemplo n.º 8
0
        public Collection <T> RunPSCommand <T>(PSCommand command, out ErrorRecord error)
        {
            PowerShellProxy powerShellProxy = null;
            Collection <T>  result          = AnchorUtil.RunTimedOperation <Collection <T> >(this.Context, delegate()
            {
                powerShellProxy = new PowerShellProxy(this.runspaceProxy, command);
                return(powerShellProxy.Invoke <T>());
            }, AnchorRunspaceProxy.GetCommandString(command));

            if (powerShellProxy.Failed)
            {
                error = powerShellProxy.Errors[0];
                return(null);
            }
            error = null;
            return(result);
        }
Ejemplo n.º 9
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.º 10
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.º 11
0
 public static AnchorRunspaceProxy CreateRunspaceForDatacenterAdmin(AnchorContext context, ADObjectId ownerId)
 {
     AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId");
     return(AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(context, ownerId.ToString()));
 }
Ejemplo n.º 12
0
 private RunspaceFactoryWithDCAffinity(string affinityToken, AnchorRunspaceProxy.FullExchangeRunspaceConfigurationFactory configurationFactory, PSHostFactory hostFactory) : base(configurationFactory, hostFactory)
 {
     AnchorUtil.ThrowOnNullOrEmptyArgument(affinityToken, "affinityToken");
     this.affinityToken = affinityToken;
 }
Ejemplo n.º 13
0
 private RunspaceFactoryWithDCAffinity(string affinityToken, InitialSessionStateFactory issFactory, PSHostFactory hostFactory) : base(issFactory, hostFactory, true)
 {
     AnchorUtil.ThrowOnNullOrEmptyArgument(affinityToken, "affinityToken");
     this.affinityToken = affinityToken;
 }
 // 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.º 15
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.º 16
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.º 17
0
 // Token: 0x0600008F RID: 143 RVA: 0x000032AE File Offset: 0x000014AE
 public T GetConfig <T>([CallerMemberName] string settingName = null)
 {
     AnchorUtil.ThrowOnNullOrEmptyArgument(settingName, "settingName");
     return(this.Provider.GetConfig <T>(settingName));
 }
Ejemplo n.º 18
0
 internal bool TryAdd(ADUser user, bool wakeCache)
 {
     AnchorUtil.ThrowOnNullArgument(user, "user");
     return(this.TryUpdate(this.Context.CreateCacheEntry(user), wakeCache));
 }
Ejemplo n.º 19
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;
 }