// Token: 0x0600124D RID: 4685 RVA: 0x000694E0 File Offset: 0x000676E0
        public AssistantTaskContext FinishProcessingOAB(AssistantTaskContext assistantTaskContext)
        {
            OABGeneratorTaskContext oabgeneratorTaskContext = assistantTaskContext as OABGeneratorTaskContext;

            OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.FinishProcessingOAB: start", new object[0]);
            try
            {
                OABLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_OABGenerationCompletedGeneration, new object[]
                {
                    oabgeneratorTaskContext.CurrentOAB.ToString(),
                    oabgeneratorTaskContext.CurrentOAB.DistinguishedName,
                    oabgeneratorTaskContext.CurrentOAB.Id.ObjectGuid,
                    (oabgeneratorTaskContext.OABGenerator.Stats != null) ? oabgeneratorTaskContext.OABGenerator.Stats.GetStringForLogging() : string.Empty
                });
            }
            finally
            {
                if (oabgeneratorTaskContext.Cleanup != null)
                {
                    oabgeneratorTaskContext.Cleanup(oabgeneratorTaskContext);
                }
                oabgeneratorTaskContext.ClearPerOABData();
                OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.FinishProcessingOAB: finish", new object[0]);
            }
            if (oabgeneratorTaskContext.OABsToGenerate != null && oabgeneratorTaskContext.OABsToGenerate.Count > 0)
            {
                oabgeneratorTaskContext.CurrentOAB = oabgeneratorTaskContext.OABsToGenerate.Dequeue();
                oabgeneratorTaskContext.OABStep    = new AssistantStep(this.BeginProcessingOAB);
                return(OABGeneratorTaskContext.FromOABGeneratorTaskContext(oabgeneratorTaskContext));
            }
            return(null);
        }
 // Token: 0x060012CB RID: 4811 RVA: 0x0006DD94 File Offset: 0x0006BF94
 private static void ReadNextRecord(Stream stream, bool isFromOldFile, ref uint recordCount, ref long fileBytesRemaining, ref byte[] recordBuffer, ref int recordBytesRemaining, ref Guid?objectGuid, ref byte[] propertyDescriptorsBuffer, ref int headerPropertyDescriptorsCount, ref int detailPropertyDescriptorsCount)
 {
     recordBuffer         = DiffFileGenerator.ReadNextUncompressedRecord(stream);
     fileBytesRemaining  -= (long)((ulong)recordBuffer.Length);
     recordBytesRemaining = recordBuffer.Length;
     recordCount         += 1U;
     if (recordCount > 2U)
     {
         object detailPropertyValue = DiffFileGenerator.GetDetailPropertyValue((PropTag)2355953922U, recordBuffer, propertyDescriptorsBuffer, headerPropertyDescriptorsCount, detailPropertyDescriptorsCount, isFromOldFile);
         objectGuid = new Guid?(new Guid((byte[])detailPropertyValue));
         return;
     }
     if (recordCount == 1U)
     {
         propertyDescriptorsBuffer      = recordBuffer;
         headerPropertyDescriptorsCount = BitConverter.ToInt32(propertyDescriptorsBuffer, 4);
         detailPropertyDescriptorsCount = BitConverter.ToInt32(propertyDescriptorsBuffer, 8 + headerPropertyDescriptorsCount * 2 * 4);
         OABLogger.LogRecord(TraceType.InfoTrace, "PropertyDescriptorsBuffer is: {0}", new object[]
         {
             BitConverter.ToString(propertyDescriptorsBuffer)
         });
         OABLogger.LogRecord(TraceType.InfoTrace, "Header property count is {0}, detail property count is {1}", new object[]
         {
             headerPropertyDescriptorsCount,
             detailPropertyDescriptorsCount
         });
     }
     objectGuid = new Guid?(Guid.Empty);
 }
        // Token: 0x06001248 RID: 4680 RVA: 0x000689D4 File Offset: 0x00066BD4
        private AssistantTaskContext InitializeContextInternal(MailboxData mailbox, TimeBasedDatabaseJob job)
        {
            OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.InitializeContextInternal: start", new object[0]);
            AssistantTaskContext result;

            try
            {
                if (mailbox is OABGeneratorMailboxData)
                {
                    result = OABGeneratorTaskContext.FromAssistantTaskContext(new AssistantTaskContext(mailbox, job, null));
                }
                else if (mailbox is StoreMailboxData)
                {
                    StoreMailboxData  storeMailboxData            = (StoreMailboxData)mailbox;
                    ADSessionSettings sessionSettings             = OABVariantConfigurationSettings.IsMultitenancyEnabled ? ADSessionSettings.FromTenantPartitionHint(storeMailboxData.TenantPartitionHint) : ADSessionSettings.FromRootOrgScopeSet();
                    ADUser            organizationalMailboxFromAD = this.GetOrganizationalMailboxFromAD(sessionSettings, storeMailboxData.Guid);
                    if (organizationalMailboxFromAD == null)
                    {
                        OABLogger.LogRecord(TraceType.ErrorTrace, "OABGeneratorAssistant.InitializeContext: ignoring scheduled job due to unknown organization mailbox: {0}", new object[]
                        {
                            storeMailboxData.Guid
                        });
                        result = null;
                    }
                    else if (organizationalMailboxFromAD.RecipientTypeDetails != RecipientTypeDetails.ArbitrationMailbox || !organizationalMailboxFromAD.PersistedCapabilities.Contains(Capability.OrganizationCapabilityOABGen))
                    {
                        OABLogger.LogRecord(TraceType.ErrorTrace, "OABGeneratorAssistant.InitializeContext: The mailbox {0} is not an organizational mailbox with OABGen capability", new object[]
                        {
                            storeMailboxData.Guid
                        });
                        result = null;
                    }
                    else
                    {
                        OABGeneratorMailboxData mailboxData             = new OABGeneratorMailboxData(organizationalMailboxFromAD.OrganizationId, base.DatabaseInfo.Guid, organizationalMailboxFromAD.ExchangeGuid, organizationalMailboxFromAD.DisplayName, organizationalMailboxFromAD.Sid, organizationalMailboxFromAD.PrimarySmtpAddress.Domain, Guid.Empty, storeMailboxData.TenantPartitionHint, string.Empty);
                        OABGeneratorTaskContext oabgeneratorTaskContext = OABGeneratorTaskContext.FromAssistantTaskContext(new AssistantTaskContext(mailboxData, job, null));
                        oabgeneratorTaskContext.OrganizationMailbox = organizationalMailboxFromAD;
                        result = oabgeneratorTaskContext;
                    }
                }
                else
                {
                    OABLogger.LogRecord(TraceType.ErrorTrace, "OABGeneratorAssistant.InitializeContext: MailboxData is neither StoreMailboxData nor OABGeneratorMailboxData", new object[0]);
                    result = null;
                }
            }
            catch (CannotResolveExternalDirectoryOrganizationIdException ex)
            {
                OABLogger.LogRecord(TraceType.ErrorTrace, "OABGeneratorAssistant.InitializeContext: {0}", new object[]
                {
                    ex.ToString()
                });
                result = null;
            }
            finally
            {
                OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.InitializeContextInternal: finish", new object[0]);
            }
            return(result);
        }
        // Token: 0x06001320 RID: 4896 RVA: 0x0006E9AC File Offset: 0x0006CBAC
        private bool TryGetLcidFromContainerName(out int lcid)
        {
            lcid = 0;
            Exception ex = null;

            try
            {
                lcid = int.Parse(this.addressTemplateContainer.Id.Name, NumberStyles.AllowHexSpecifier);
            }
            catch (ArgumentException ex2)
            {
                ex = ex2;
            }
            catch (FormatException ex3)
            {
                ex = ex3;
            }
            catch (OverflowException ex4)
            {
                ex = ex4;
            }
            if (ex == null)
            {
                return(true);
            }
            OABLogger.LogRecord(TraceType.ErrorTrace, "TemplateFileGenerator.TryGetLcidFromContainerName: Could not parse a valid LCID from container name {0}.  Exception: {1}", new object[]
            {
                this.addressTemplateContainer.Id.Name,
                ex
            });
            return(false);
        }
        // Token: 0x06001250 RID: 4688 RVA: 0x000696B4 File Offset: 0x000678B4
        private ADUser GetOrganizationalMailboxFromAD(ADSessionSettings sessionSettings, Guid mailboxGuid)
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 733, "GetOrganizationalMailboxFromAD", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\OABGenerator\\OABGeneratorAssistant.cs");
            ADRecipient       adrecipient;

            try
            {
                adrecipient = tenantOrRootOrgRecipientSession.FindByExchangeGuid(mailboxGuid);
            }
            catch (NonUniqueRecipientException)
            {
                OABGeneratorAssistant.Tracer.TraceError <Guid>((long)this.GetHashCode(), "OABGeneratorAssistant.GetOrganizationalMailboxFromAD: multiple mailboxes have ExchangeGuid={0}", mailboxGuid);
                OABLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_OrganizationalMailboxGuidIsNotUnique, new object[]
                {
                    mailboxGuid
                });
                return(null);
            }
            if (adrecipient == null)
            {
                OABGeneratorAssistant.Tracer.TraceError <Guid>((long)this.GetHashCode(), "OABGeneratorAssistant.GetOrganizationalMailboxFromAD: unable to find user object with ExchangeGuid={0}", mailboxGuid);
                return(null);
            }
            ADUser aduser = adrecipient as ADUser;

            if (aduser == null)
            {
                OABGeneratorAssistant.Tracer.TraceError <Guid>((long)this.GetHashCode(), "OABGeneratorAssistant.GetOrganizationalMailboxFromAD: unknown organization mailbox: {0}", mailboxGuid);
                return(null);
            }
            return(aduser);
        }
Example #6
0
 // Token: 0x0600131B RID: 4891 RVA: 0x0006E74E File Offset: 0x0006C94E
 private static void LogToFile(TraceType traceType, string formatString, params object[] args)
 {
     if (!OABLogger.Instance.Enabled)
     {
         OABLogger.Instance.SafeTraceDebug(0L, "Mailbox assistant log is disabled, skip writing to the log file.", new object[0]);
         return;
     }
     OABLogger.LogToFile(traceType, string.Format(formatString, args));
 }
        // Token: 0x06001251 RID: 4689 RVA: 0x00069774 File Offset: 0x00067974
        private Queue <OfflineAddressBook> GetOABsFromAD(OABGeneratorTaskContext context, Guid oabObjectGuid)
        {
            OABGeneratorAssistant.Tracer.TraceFunction <Guid>((long)this.GetHashCode(), "GetOABsFromAD. oabObjectGuid={0}", oabObjectGuid);
            Queue <OfflineAddressBook> queue = new Queue <OfflineAddressBook>();

            if (oabObjectGuid == Guid.Empty)
            {
                OfflineAddressBook[] array = this.GetCandidateOABsFromAD(context) ?? new OfflineAddressBook[0];
                OABLogger.LogRecord(TraceType.InfoTrace, "OABGeneratorAssistant.GetCandidateOABSFromAD() returned {0} oab(s)", new object[]
                {
                    array.Length.ToString()
                });
                foreach (OfflineAddressBook offlineAddressBook in array)
                {
                    if (!this.OABAddressListsAreValid(offlineAddressBook))
                    {
                        OABLogger.LogRecord(TraceType.ErrorTrace, "OABGeneratorAssistant.GetOABsFromAD: address list is invalid: {0}.", new object[]
                        {
                            offlineAddressBook.Id
                        });
                    }
                    else if (this.isRunningFromInvoke)
                    {
                        queue.Enqueue(offlineAddressBook);
                    }
                    else if (OABVariantConfigurationSettings.IsGenerateRequestedOABsOnlyEnabled && (offlineAddressBook.LastRequestedTime == null || DateTime.UtcNow - offlineAddressBook.LastRequestedTime.Value >= Globals.LastRequestedTimeGenerationWindow))
                    {
                        OABLogger.LogRecord(TraceType.ErrorTrace, "OABGeneratorAssistant.GetOABsFromAD: LastRequestedTime for OAB {0} is beyond generation window - LastRequestedTime: {1}, LastRequestedTimeWindow: {2}", new object[]
                        {
                            offlineAddressBook.Id,
                            (offlineAddressBook.LastRequestedTime != null) ? offlineAddressBook.LastRequestedTime.Value.ToString() : "null",
                            Globals.LastRequestedTimeGenerationWindow
                        });
                    }
                    else
                    {
                        queue.Enqueue(offlineAddressBook);
                    }
                }
            }
            else
            {
                OfflineAddressBook specificOABFromAD = this.GetSpecificOABFromAD(context, oabObjectGuid);
                if (specificOABFromAD != null && this.OABAddressListsAreValid(specificOABFromAD))
                {
                    queue.Enqueue(specificOABFromAD);
                }
            }
            OABLogger.LogRecord(TraceType.InfoTrace, "OABGeneratorAssistant.GetOABsFromAD() returned {0} oab(s)", new object[]
            {
                queue.Count
            });
            return(queue);
        }
Example #8
0
            // Token: 0x0600135E RID: 4958 RVA: 0x00070DE0 File Offset: 0x0006EFE0
            public override void AddPropertyValue(ADRawEntry adRawEntry, PropRow propRow, OABFileRecord oabFileRecord, int index)
            {
                PropValue propValue = propRow.Properties[index];

                if (propValue.IsError())
                {
                    return;
                }
                try
                {
                    if (propValue.PropType == PropType.StringArray)
                    {
                        string[] stringArray = propValue.GetStringArray();
                        if (stringArray != null)
                        {
                            string[] value = (from s in stringArray
                                              select this.ValidString(s, adRawEntry.Id.ToString(), propValue.PropTag.ToString()) into v
                                              orderby v
                                              select v).ToArray <string>();
                            oabFileRecord.PropertyValues[index] = new OABPropertyValue
                            {
                                PropTag = this.propTag,
                                Value   = value
                            };
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    OABLogger.LogRecord(TraceType.DebugTrace, "MultivaluedProperty.AddPropertyValue: Informational only: Unable to validate strings in object {0}, property {1}. Reason: {2}", new object[]
                    {
                        adRawEntry.Id.ToString(),
                        propValue.PropTag.ToString(),
                        ex.Message
                    });
                }
                object obj = this.SortValues(propValue);

                if (obj != null)
                {
                    oabFileRecord.PropertyValues[index] = new OABPropertyValue
                    {
                        PropTag = this.propTag,
                        Value   = obj
                    };
                }
            }
Example #9
0
        // Token: 0x0600132D RID: 4909 RVA: 0x0006F36C File Offset: 0x0006D56C
        public static Exception RunSafeADOperation(ADOperation adOperation, string details)
        {
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(adOperation, 5);

            if (!adoperationResult.Succeeded)
            {
                OABLogger.LogRecord(TraceType.ErrorTrace, "RunSafeADOperation failed with ErrorCode: {0}, Exception: {1}. Operation Details: {2}", new object[]
                {
                    adoperationResult.ErrorCode,
                    adoperationResult.Exception,
                    string.IsNullOrEmpty(details) ? "null" : details
                });
                return(adoperationResult.Exception);
            }
            return(null);
        }
Example #10
0
        // Token: 0x06001352 RID: 4946 RVA: 0x00070B9C File Offset: 0x0006ED9C
        private string ValidString(string valueString, string id, string prop)
        {
            int num = valueString.IndexOf('\0');

            if (num >= 0)
            {
                OABLogger.LogRecord(TraceType.DebugTrace, "OABProperty.AddPropertyValue: Object {0}. Property {1} has non-terminating NULL char. Value {2} discarded.", new object[]
                {
                    id,
                    prop,
                    valueString
                });
                return(OABProperty.ReplacementString);
            }
            return(valueString);
        }
        // Token: 0x060012C5 RID: 4805 RVA: 0x0006D9C4 File Offset: 0x0006BBC4
        private static object GetPropertyValue(PropTag propTag, byte[] recordBuffer, ref int propertyOffset, bool isFromOldFile)
        {
            PropType propType = propTag.ValueType() & (PropType)(-4097);
            object   result;

            switch (propType)
            {
            case PropType.AnsiString:
            case PropType.String:
            {
                int num = propertyOffset;
                while (recordBuffer[propertyOffset] != 0)
                {
                    propertyOffset++;
                }
                result = Encoding.UTF8.GetString(recordBuffer, num, propertyOffset - num);
                break;
            }

            default:
            {
                if (propType != PropType.Binary)
                {
                    throw new NotSupportedException(string.Format("GetProperty doesn't support property type {0} now", propTag.ValueType()));
                }
                int num2;
                DiffFileGenerator.GetV4IntegerValue(recordBuffer, ref propertyOffset, out num2);
                if (num2 <= 0)
                {
                    OABLogger.LogRecord(TraceType.FatalTrace, "Invalid binary property data for tag {0} from {1} file . The offset is {2}. The binary blob is {3}", new object[]
                        {
                            propTag.ToString(),
                            isFromOldFile ? "old" : "new",
                            propertyOffset,
                            BitConverter.ToString(recordBuffer)
                        });
                    throw new InvalidDataException(string.Format("Invalid binary property data for tag {0}", propTag.ToString()));
                }
                byte[] array = new byte[num2];
                Array.Copy(recordBuffer, propertyOffset, array, 0, num2);
                propertyOffset += num2;
                result          = array;
                break;
            }
            }
            return(result);
        }
 // Token: 0x0600124A RID: 4682 RVA: 0x00068FE8 File Offset: 0x000671E8
 public AssistantTaskContext ProcessAssistantStep(AssistantTaskContext assistantTaskContext)
 {
     OABGeneratorAssistant.< > c__DisplayClasse CS$ < > 8__locals1 = new OABGeneratorAssistant.< > c__DisplayClasse();
     CS$ < > 8__locals1.< > 4__this = this;
     CS$ < > 8__locals1.context     = (assistantTaskContext as OABGeneratorTaskContext);
     if (CS$ < > 8__locals1.context == null || CS$ < > 8__locals1.context.OABStep == null)
     {
         OABLogger.LogRecord(TraceType.ErrorTrace, "OABGeneratorAssistant.ProcessAssistantStep: Null or bad context passed in to OABGeneratorAssistant.ProcessAssistantStep; aborting OAB generation.", new object[0]);
         return(null);
     }
     CS$ < > 8__locals1.nextContext = null;
     ILUtil.DoTryFilterCatch(new TryDelegate(CS$ < > 8__locals1, (UIntPtr)ldftn(< ProcessAssistantStep > b__9)), new FilterDelegate(this, (UIntPtr)ldftn(< ProcessAssistantStep > b__c)), new CatchDelegate(CS$ < > 8__locals1, (UIntPtr)ldftn(< ProcessAssistantStep > b__d)));
     if (CS$ < > 8__locals1.nextContext == null || CS$ < > 8__locals1.nextContext.OABStep == null)
     {
         return(null);
     }
     return(CS$ < > 8__locals1.nextContext);
 }
        // Token: 0x0600124C RID: 4684 RVA: 0x00069300 File Offset: 0x00067500
        public AssistantTaskContext BeginProcessingOAB(AssistantTaskContext assistantTaskContext)
        {
            OABGeneratorTaskContext oabgeneratorTaskContext = assistantTaskContext as OABGeneratorTaskContext;
            AssistantStep           assistantStep           = null;

            OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.BeginProcessingOAB: start", new object[0]);
            OABGeneratorMailboxData oabgeneratorMailboxData = (OABGeneratorMailboxData)oabgeneratorTaskContext.Args.MailboxData;

            try
            {
                lock (this.currentOABsInProcessing)
                {
                    if (this.currentOABsInProcessing.Contains(oabgeneratorTaskContext.CurrentOAB.Id.ObjectGuid))
                    {
                        OABGeneratorAssistant.Tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "OABGeneratorAssistant.BeginProcessingOAB: ignoring on-demand request requested OAB is already in processing: {0}.", oabgeneratorTaskContext.CurrentOAB.Id);
                        return(null);
                    }
                    this.currentOABsInProcessing.Add(oabgeneratorTaskContext.CurrentOAB.Id.ObjectGuid);
                }
                OABGeneratorTaskContext oabgeneratorTaskContext2 = oabgeneratorTaskContext;
                oabgeneratorTaskContext2.Cleanup     = (Action <OABGeneratorTaskContext>)Delegate.Combine(oabgeneratorTaskContext2.Cleanup, new Action <OABGeneratorTaskContext>(this.RemoveCurrentOABFromInProcessingList));
                oabgeneratorTaskContext.OABGenerator = new OABGenerator(oabgeneratorTaskContext.PerOrgAdSystemConfigSession, oabgeneratorTaskContext.CurrentOAB, oabgeneratorMailboxData.MailboxSid, oabgeneratorMailboxData.MailboxDomain, new Action(this.AbortProcessingOnShutdown));
                OABLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_OABGenerationStartGeneration, new object[]
                {
                    oabgeneratorTaskContext.CurrentOAB,
                    oabgeneratorTaskContext.CurrentOAB.DistinguishedName,
                    oabgeneratorTaskContext.CurrentOAB.Id.ObjectGuid
                });
                oabgeneratorTaskContext.OABGenerator.Initialize();
                oabgeneratorTaskContext.ReturnStep.Push(new AssistantStep(this.FinishProcessingOAB));
                assistantStep = new AssistantStep(oabgeneratorTaskContext.OABGenerator.PrepareFilesForOABGeneration);
            }
            finally
            {
                OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.BeginProcessingOAB: finish", new object[0]);
                if (assistantStep != null)
                {
                    oabgeneratorTaskContext.OABStep = assistantStep;
                }
            }
            return(OABGeneratorTaskContext.FromOABGeneratorTaskContext(oabgeneratorTaskContext));
        }
Example #14
0
        // Token: 0x06001239 RID: 4665 RVA: 0x000684E4 File Offset: 0x000666E4
        public void Log(string marker, string counter, uint dataPoint)
        {
            string text = string.Format("I32:{0}.{1}", marker, counter);
            long   num  = (long)((ulong)dataPoint);

            if (this.CounterBasedPerfStats.ContainsKey(text))
            {
                num += this.CounterBasedPerfStats[text];
            }
            else
            {
                this.stagePerfStatsOrder.Add(text);
            }
            this.CounterBasedPerfStats[text] = num;
            OABLogger.LogRecord(TraceType.InfoTrace, "GenerationStats.Log: I32:{0}.{1} += {2}", new object[]
            {
                marker,
                counter,
                dataPoint
            });
        }
Example #15
0
        // Token: 0x06001238 RID: 4664 RVA: 0x00068468 File Offset: 0x00066668
        public void Log(string marker, string counter, TimeSpan dataPoint)
        {
            string   text     = string.Format("Ti:{0}.{1}", marker, counter);
            TimeSpan timeSpan = dataPoint;

            if (this.StagePerfStats.ContainsKey(text))
            {
                timeSpan += this.StagePerfStats[text];
            }
            else
            {
                this.stagePerfStatsOrder.Add(text);
            }
            this.StagePerfStats[text] = timeSpan;
            OABLogger.LogRecord(TraceType.InfoTrace, "GenerationStats.Log: Ti:{0}.{1} += {2}", new object[]
            {
                marker,
                counter,
                dataPoint
            });
        }
Example #16
0
        // Token: 0x06001338 RID: 4920 RVA: 0x0006FD1C File Offset: 0x0006DF1C
        public AssistantTaskContext ProduceSortedFlatFile(AssistantTaskContext assistantTaskContext)
        {
            OABGeneratorTaskContext oabgeneratorTaskContext = assistantTaskContext as OABGeneratorTaskContext;
            AssistantStep           oabstep = oabgeneratorTaskContext.ReturnStep.Pop();

            OABLogger.LogRecord(TraceType.FunctionTrace, "AddressListFileGenerator.ProduceSortedFlatFile: start", new object[0]);
            try
            {
                using (new StopwatchPerformanceTracker("Total", this.stats))
                {
                    using (new CpuPerformanceTracker("Total", this.stats))
                    {
                        using (new StopwatchPerformanceTracker("ProduceSortedFlatFile", this.stats))
                        {
                            using (new CpuPerformanceTracker("ProduceSortedFlatFile", this.stats))
                            {
                                this.stats.DomainControllersUsed.Add(this.adAddressListEnumerator.LastUsedDc);
                                this.uncompressedSortedFlatFile = this.fileSet.Create("OAB");
                                if (this.allResultsInSinglePage)
                                {
                                    this.CreateFlatFileFromSinglePageOfResults(this.uncompressedSortedFlatFile, this.sortedEntries);
                                }
                                else
                                {
                                    this.CreateFlatFileFromMultiplePagesOfResults(this.uncompressedSortedFlatFile, this.tempFiles);
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                OABLogger.LogRecord(TraceType.FunctionTrace, "AddressListFileGenerator.ProduceSortedFlatFile: finish", new object[0]);
                oabgeneratorTaskContext.OABStep = oabstep;
            }
            return(OABGeneratorTaskContext.FromOABGeneratorTaskContext(oabgeneratorTaskContext));
        }
Example #17
0
        // Token: 0x06001312 RID: 4882 RVA: 0x0006E508 File Offset: 0x0006C708
        public static void LogEvent(ExEventLog.EventTuple eventTuple, params object[] args)
        {
            OABLogger.eventLog.LogEvent(eventTuple, null, args);
            string text = string.Format("Logged Event Id {0}.", eventTuple.EventId);

            if (args != null)
            {
                text += " Params: ";
                for (int i = 0; i < args.Length; i++)
                {
                    object obj = text;
                    text = string.Concat(new object[]
                    {
                        obj,
                        (i == 0) ? string.Empty : "||",
                        "{",
                        i,
                        "}"
                    });
                }
            }
            string.Format(text, args);
            switch (eventTuple.EntryType)
            {
            case EventLogEntryType.Error:
                OABLogger.LogRecord(TraceType.ErrorTrace, text, args);
                return;

            case EventLogEntryType.Warning:
                OABLogger.LogRecord(TraceType.WarningTrace, text, args);
                return;

            default:
                OABLogger.LogRecord(TraceType.DebugTrace, text, args);
                return;
            }
        }
 // Token: 0x06001253 RID: 4691 RVA: 0x00069994 File Offset: 0x00067B94
 private OfflineAddressBook[] GetCandidateOABsFromAD(OABGeneratorTaskContext context)
 {
     if (!OABVariantConfigurationSettings.IsLinkedOABGenMailboxesEnabled)
     {
         QueryFilter filter = OABGeneratorAssistant.versionFilter;
         return(context.PerOrgAdSystemConfigSession.Find <OfflineAddressBook>(null, QueryScope.SubTree, filter, null, 0));
     }
     if (context.OrganizationMailbox == null)
     {
         ADSessionSettings sessionSettings = OABVariantConfigurationSettings.IsMultitenancyEnabled ? ADSessionSettings.FromTenantPartitionHint(((OABGeneratorMailboxData)context.MailboxData).TenantPartitionHint) : ADSessionSettings.FromRootOrgScopeSet();
         context.OrganizationMailbox = this.GetOrganizationalMailboxFromAD(sessionSettings, ((OABGeneratorMailboxData)context.MailboxData).Guid);
     }
     if (context.OrganizationMailbox.GeneratedOfflineAddressBooks != null && context.OrganizationMailbox.GeneratedOfflineAddressBooks.Count > 0)
     {
         OABLogger.LogRecord(TraceType.InfoTrace, "OABGeneratorAssistant.GetCandidateOABsFromAD: Found {0} generated offline address books in org mailbox {1}", new object[]
         {
             context.OrganizationMailbox.GeneratedOfflineAddressBooks.Count.ToString(),
             context.OrganizationMailbox.Id
         });
         List <OfflineAddressBook> list = new List <OfflineAddressBook>(context.OrganizationMailbox.GeneratedOfflineAddressBooks.Count);
         foreach (ADObjectId entryId in context.OrganizationMailbox.GeneratedOfflineAddressBooks)
         {
             OfflineAddressBook offlineAddressBook = context.PerOrgAdSystemConfigSession.Read <OfflineAddressBook>(entryId);
             if (offlineAddressBook != null)
             {
                 list.Add(offlineAddressBook);
             }
         }
         return(list.ToArray());
     }
     OABLogger.LogRecord(TraceType.InfoTrace, "OABGeneratorAssistant.GetCandidateOABsFromAD: No offline address books found in org mailbox {0}", new object[]
     {
         context.OrganizationMailbox.Id
     });
     return(null);
 }
Example #19
0
 // Token: 0x0600130A RID: 4874 RVA: 0x0006E46E File Offset: 0x0006C66E
 public void TracePerformance(long id, string message)
 {
     OABLogger.diagnosticTracer.TracePerformance(id, message);
     OABLogger.LogToFile(TraceType.PerformanceTrace, message);
 }
Example #20
0
 // Token: 0x0600130B RID: 4875 RVA: 0x0006E483 File Offset: 0x0006C683
 public void TracePerformance(long id, string formatString, params object[] args)
 {
     OABLogger.diagnosticTracer.TracePerformance(id, formatString, args);
     OABLogger.LogToFile(TraceType.PerformanceTrace, formatString, args);
 }
Example #21
0
            // Token: 0x0600135F RID: 4959 RVA: 0x00070F58 File Offset: 0x0006F158
            protected object SortValues(PropValue propValue)
            {
                object value;

                try
                {
                    PropType propType = propValue.PropType;
                    if (propType <= PropType.LongArray)
                    {
                        switch (propType)
                        {
                        case PropType.ShortArray:
                        {
                            short[] shortArray = propValue.GetShortArray();
                            if (shortArray != null)
                            {
                                Array.Sort <short>(shortArray);
                                return(shortArray);
                            }
                            return(propValue.Value);
                        }

                        case PropType.IntArray:
                        {
                            int[] intArray = propValue.GetIntArray();
                            if (intArray != null)
                            {
                                Array.Sort <int>(intArray);
                                return(intArray);
                            }
                            return(propValue.Value);
                        }

                        case PropType.FloatArray:
                        {
                            float[] floatArray = propValue.GetFloatArray();
                            if (floatArray != null)
                            {
                                Array.Sort <float>(floatArray);
                                return(floatArray);
                            }
                            return(propValue.Value);
                        }

                        case PropType.DoubleArray:
                        {
                            double[] doubleArray = propValue.GetDoubleArray();
                            if (doubleArray != null)
                            {
                                Array.Sort <double>(doubleArray);
                                return(doubleArray);
                            }
                            return(propValue.Value);
                        }

                        default:
                            if (propType == PropType.LongArray)
                            {
                                long[] longArray = propValue.GetLongArray();
                                if (longArray != null)
                                {
                                    Array.Sort <long>(longArray);
                                    return(longArray);
                                }
                                return(propValue.Value);
                            }
                            break;
                        }
                    }
                    else
                    {
                        switch (propType)
                        {
                        case PropType.AnsiStringArray:
                        case PropType.StringArray:
                        {
                            string[] stringArray = propValue.GetStringArray();
                            if (stringArray != null)
                            {
                                Array.Sort <string>(stringArray);
                                return(stringArray);
                            }
                            return(propValue.Value);
                        }

                        default:
                            if (propType != PropType.GuidArray)
                            {
                                if (propType == PropType.BinaryArray)
                                {
                                    byte[][] bytesArray = propValue.GetBytesArray();
                                    if (bytesArray != null)
                                    {
                                        Array.Sort <byte[]>(bytesArray, ArrayComparer <byte> .Comparer);
                                        return(bytesArray);
                                    }
                                    return(propValue.Value);
                                }
                            }
                            else
                            {
                                Guid[] guidArray = propValue.GetGuidArray();
                                if (guidArray != null)
                                {
                                    Array.Sort <Guid>(guidArray);
                                    return(guidArray);
                                }
                                return(propValue.Value);
                            }
                            break;
                        }
                    }
                    OABLogger.LogRecord(TraceType.ErrorTrace, "MultivaluedProperty.SortValues: don't know how to deal with type {0}", new object[]
                    {
                        propValue.PropType
                    });
                    value = propValue.Value;
                }
                catch (InvalidCastException)
                {
                    OABLogger.LogRecord(TraceType.ErrorTrace, "MultivaluedProperty.SortValues: InvalidCastException while handling property {0} of stated type {1}", new object[]
                    {
                        this.propertyDefinition.Name,
                        propValue.PropType
                    });
                    value = propValue.Value;
                }
                return(value);
            }
        // Token: 0x0600124B RID: 4683 RVA: 0x00069084 File Offset: 0x00067284
        public AssistantTaskContext InitializeOABGeneration(AssistantTaskContext assistantTaskContext)
        {
            OABGeneratorTaskContext oabgeneratorTaskContext = assistantTaskContext as OABGeneratorTaskContext;
            AssistantStep           oabstep = new AssistantStep(this.BeginProcessingOAB);

            OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.InitialStep: start", new object[0]);
            OABGeneratorMailboxData oabgeneratorMailboxData = (OABGeneratorMailboxData)oabgeneratorTaskContext.Args.MailboxData;

            try
            {
                OrganizationId organizationId = oabgeneratorMailboxData.OrganizationId;
                if (organizationId == null)
                {
                    throw new ArgumentException("unable to determine organization Id");
                }
                oabgeneratorTaskContext.PerOrgAdSystemConfigSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), 502, "InitializeOABGeneration", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\OABGenerator\\OABGeneratorAssistant.cs");
                if (oabgeneratorMailboxData.OfflineAddressBook == Guid.Empty)
                {
                    OABLogger.LogRecord(TraceType.InfoTrace, "OABGenerator invoked for scheduled generation of OABs for Org '{0}' on DatabaseGuid={1}", new object[]
                    {
                        organizationId,
                        oabgeneratorTaskContext.Args.MailboxData.DatabaseGuid
                    });
                    oabgeneratorTaskContext.OABsToGenerate = this.GetOABsFromAD(oabgeneratorTaskContext, Guid.Empty);
                }
                else
                {
                    OABLogger.LogRecord(TraceType.InfoTrace, "OABGenerator invoked {0} for on-demand generation of OAB {1} for Org {2} DatabaseGuid={3}, MailboxGuid={4}", new object[]
                    {
                        oabgeneratorMailboxData.JobDescription,
                        oabgeneratorMailboxData.OfflineAddressBook,
                        organizationId,
                        oabgeneratorTaskContext.Args.MailboxData.DatabaseGuid,
                        oabgeneratorMailboxData.MailboxGuid
                    });
                    oabgeneratorTaskContext.OABsToGenerate = this.GetOABsFromAD(oabgeneratorTaskContext, oabgeneratorMailboxData.OfflineAddressBook);
                    if (oabgeneratorTaskContext.OABsToGenerate == null || oabgeneratorTaskContext.OABsToGenerate.Count != 1)
                    {
                        OABLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_CannotFindOAB, new object[]
                        {
                            oabgeneratorMailboxData.OfflineAddressBook
                        });
                    }
                }
                if (oabgeneratorTaskContext.OABsToGenerate == null || oabgeneratorTaskContext.OABsToGenerate.Count == 0)
                {
                    OABLogger.LogRecord(TraceType.InfoTrace, "InvokeInternal. No OABs found to generate for DatabaseGuid={0}, MailboxGuid={1}", new object[]
                    {
                        oabgeneratorMailboxData.DatabaseGuid,
                        oabgeneratorMailboxData.MailboxGuid.ToString(),
                        oabgeneratorMailboxData.Guid
                    });
                    if (oabgeneratorTaskContext.Cleanup != null)
                    {
                        oabgeneratorTaskContext.Cleanup(oabgeneratorTaskContext);
                    }
                    return(null);
                }
                OABLogger.LogRecord(TraceType.InfoTrace, "Found {0} OAB(s) to generate", new object[]
                {
                    oabgeneratorTaskContext.OABsToGenerate.Count
                });
                oabgeneratorTaskContext.CurrentOAB = oabgeneratorTaskContext.OABsToGenerate.Dequeue();
            }
            finally
            {
                OABLogger.LogRecord(TraceType.FunctionTrace, "OABGeneratorAssistant.InitialStep: finish", new object[0]);
                oabgeneratorTaskContext.OABStep = oabstep;
            }
            return(OABGeneratorTaskContext.FromOABGeneratorTaskContext(oabgeneratorTaskContext));
        }
Example #23
0
 // Token: 0x0600130E RID: 4878 RVA: 0x0006E4CC File Offset: 0x0006C6CC
 public void TracePerformance <T0, T1, T2>(long id, string formatString, T0 arg0, T1 arg1, T2 arg2)
 {
     OABLogger.diagnosticTracer.TracePerformance <T0, T1, T2>(id, formatString, arg0, arg1, arg2);
     OABLogger.LogToFile <T0, T1, T2>(TraceType.PerformanceTrace, formatString, arg0, arg1, arg2);
 }
        // Token: 0x06001254 RID: 4692 RVA: 0x00069B14 File Offset: 0x00067D14
        private bool OABAddressListsAreValid(OfflineAddressBook oab)
        {
            bool       flag       = true;
            ADObjectId adobjectId = null;

            foreach (ADObjectId adobjectId2 in oab.AddressLists)
            {
                if (string.IsNullOrEmpty(adobjectId2.DistinguishedName))
                {
                    flag       = false;
                    adobjectId = adobjectId2;
                    OABLogger.LogRecord(TraceType.ErrorTrace, "Address list id {0} is not valid because it does not have a DN", new object[]
                    {
                        adobjectId2
                    });
                    break;
                }
                if (!ADObjectId.IsValidDistinguishedName(adobjectId2.DistinguishedName))
                {
                    flag       = false;
                    adobjectId = adobjectId2;
                    OABLogger.LogRecord(TraceType.ErrorTrace, "Address list id {0} is not valid because the DN is not validly formed", new object[]
                    {
                        adobjectId2.DistinguishedName
                    });
                    break;
                }
                if (adobjectId2.IsDeleted)
                {
                    flag       = false;
                    adobjectId = adobjectId2;
                    OABLogger.LogRecord(TraceType.ErrorTrace, "Address list id {0} is not valid because it is a deleted object", new object[]
                    {
                        adobjectId2.DistinguishedName
                    });
                    break;
                }
                bool flag2 = adobjectId2.DistinguishedName.IndexOf(",CN=LostAndFound,DC=", StringComparison.OrdinalIgnoreCase) != -1;
                bool flag3 = adobjectId2.DistinguishedName.IndexOf(",CN=LostAndFoundConfig,CN=Configuration,DC=", StringComparison.OrdinalIgnoreCase) != -1;
                if (flag2 || flag3)
                {
                    flag       = false;
                    adobjectId = adobjectId2;
                    OABLogger.LogRecord(TraceType.ErrorTrace, "Address list id {0} is not valid because it is a deleted object", new object[]
                    {
                        adobjectId2.DistinguishedName
                    });
                    break;
                }
                bool flag4 = adobjectId2.DistinguishedName.IndexOf(GlobalAddressList.RdnGalContainerToOrganization.DistinguishedName, StringComparison.OrdinalIgnoreCase) > 0;
                bool flag5 = adobjectId2.DistinguishedName.IndexOf(AddressList.RdnAlContainerToOrganization.DistinguishedName, StringComparison.OrdinalIgnoreCase) > 0;
                if (!flag4 && !flag5)
                {
                    flag       = false;
                    adobjectId = adobjectId2;
                    OABLogger.LogRecord(TraceType.ErrorTrace, "Address list id {0} is not valid because it is not a child or descendant of either the All Global Address Lists or All Address Lists container", new object[]
                    {
                        adobjectId2.DistinguishedName
                    });
                    break;
                }
            }
            if (!flag && adobjectId != null)
            {
                OABLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_OABNotProcessedBecauseAddressListIsInvalid, new object[]
                {
                    oab.Identity,
                    string.IsNullOrEmpty(adobjectId.DistinguishedName) ? adobjectId.ToString() : adobjectId.DistinguishedName
                });
                OABLogger.LogRecord(TraceType.ErrorTrace, "Address list errors found in OAB {0}, address list {1}", new object[]
                {
                    oab.Id,
                    string.IsNullOrEmpty(adobjectId.DistinguishedName) ? adobjectId.ToString() : adobjectId.DistinguishedName
                });
            }
            return(flag);
        }
Example #25
0
 // Token: 0x06001308 RID: 4872 RVA: 0x0006E434 File Offset: 0x0006C634
 public void TraceError <T0, T1>(long id, string formatString, T0 arg0, T1 arg1)
 {
     OABLogger.diagnosticTracer.TraceError <T0, T1>(id, formatString, arg0, arg1);
     OABLogger.LogToFile <T0, T1>(TraceType.ErrorTrace, formatString, arg0, arg1);
 }
Example #26
0
        // Token: 0x06001337 RID: 4919 RVA: 0x0006F84C File Offset: 0x0006DA4C
        public AssistantTaskContext ProcessOnePageOfADResults(AssistantTaskContext assistantTaskContext)
        {
            OABGeneratorTaskContext oabgeneratorTaskContext = assistantTaskContext as OABGeneratorTaskContext;
            AssistantStep           oabstep = new AssistantStep(this.ProduceSortedFlatFile);

            OABLogger.LogRecord(TraceType.FunctionTrace, "AddressListFileGenerator.ProcessOnePageOfADResults: start", new object[0]);
            try
            {
                using (new StopwatchPerformanceTracker("Total", this.stats))
                {
                    using (new CpuPerformanceTracker("Total", this.stats))
                    {
                        using (new StopwatchPerformanceTracker("ProcessOnePageOfADResults", this.stats))
                        {
                            using (new CpuPerformanceTracker("ProcessOnePageOfADResults", this.stats))
                            {
                                if (this.adAddressListEnumerator.RetrievedAllData == null || !this.adAddressListEnumerator.RetrievedAllData.Value)
                                {
                                    this.sortedEntries          = this.adAddressListEnumerator.GetNextPageSorted();
                                    this.allResultsInSinglePage = (this.firstPage && this.adAddressListEnumerator.RetrievedAllData != null && this.adAddressListEnumerator.RetrievedAllData.Value);
                                    this.firstPage = false;
                                    if (!this.allResultsInSinglePage)
                                    {
                                        using (new StopwatchPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats))
                                        {
                                            using (new CpuPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats))
                                            {
                                                using (new ADPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats))
                                                {
                                                    using (new ActiveManagerPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats))
                                                    {
                                                        this.propertyManager.ResolveLinks(this.sortedEntries);
                                                    }
                                                }
                                            }
                                        }
                                        FileStream fileStream = this.fileSet.Create("TMP");
                                        this.tempFiles.Add(fileStream);
                                        this.stats.TotalNumberOfTempFiles++;
                                        using (new StopwatchPerformanceTracker("ProcessOnePageOfADResults.WriteTempFiles", this.stats))
                                        {
                                            using (new CpuPerformanceTracker("ProcessOnePageOfADResults.WriteTempFiles", this.stats))
                                            {
                                                using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(fileStream)))
                                                {
                                                    using (new FileSystemPerformanceTracker("ProcessOnePageOfADResults.WriteTempFiles", iocostStream, this.stats))
                                                    {
                                                        using (BinaryWriter binaryWriter = new BinaryWriter(iocostStream))
                                                        {
                                                            foreach (ADRawEntry adrawEntry in this.sortedEntries)
                                                            {
                                                                this.abortProcessingOnShutdown();
                                                                OABFileRecord oabfileRecord = this.CreateDetailsRecord(adrawEntry);
                                                                binaryWriter.Write(((Guid)adrawEntry[ADObjectSchema.ExchangeObjectId]).ToByteArray());
                                                                oabfileRecord.WriteTo(binaryWriter);
                                                            }
                                                            this.stats.IODuration += iocostStream.Writing;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (this.adAddressListEnumerator.RetrievedAllData == null || !this.adAddressListEnumerator.RetrievedAllData.Value)
                                {
                                    oabstep = new AssistantStep(this.ProcessOnePageOfADResults);
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                OABLogger.LogRecord(TraceType.FunctionTrace, "AddressListFileGenerator.ProcessOnePageOfADResults: finish", new object[0]);
                oabgeneratorTaskContext.OABStep = oabstep;
            }
            return(OABGeneratorTaskContext.FromOABGeneratorTaskContext(oabgeneratorTaskContext));
        }
Example #27
0
 // Token: 0x06001304 RID: 4868 RVA: 0x0006E3DA File Offset: 0x0006C5DA
 public void TraceWarning(long id, string formatString, params object[] args)
 {
     OABLogger.diagnosticTracer.TraceWarning(id, formatString, args);
     OABLogger.LogToFile(TraceType.WarningTrace, formatString, args);
 }
Example #28
0
 // Token: 0x06001313 RID: 4883 RVA: 0x0006E5D4 File Offset: 0x0006C7D4
 public static void LogRecord(TraceType traceType, string formatString, params object[] args)
 {
     OABLogger.DiagnosticTrace(traceType, formatString, args);
     OABLogger.LogToFile(traceType, formatString, args);
 }
Example #29
0
 // Token: 0x06001303 RID: 4867 RVA: 0x0006E3C5 File Offset: 0x0006C5C5
 public void TraceWarning(long id, string message)
 {
     OABLogger.diagnosticTracer.TraceWarning(id, message);
     OABLogger.LogToFile(TraceType.WarningTrace, message);
 }
Example #30
0
 // Token: 0x06001305 RID: 4869 RVA: 0x0006E3F1 File Offset: 0x0006C5F1
 public void TraceError(long id, string message)
 {
     OABLogger.diagnosticTracer.TraceError(id, message);
     OABLogger.LogToFile(TraceType.ErrorTrace, message);
 }