Exemplo n.º 1
0
        // Token: 0x060010B1 RID: 4273 RVA: 0x00061FC4 File Offset: 0x000601C4
        public static void RemoveGroupMetricsDirectory()
        {
            string path = GroupMetricsUtility.GetGroupMetricsDirectoryPath();

            GroupMetricsUtility.TryDiskOperation(delegate
            {
                Directory.Delete(path, true);
                GroupMetricsUtility.Tracer.TraceDebug <string>(0L, "RemoveDistributionDirectory succeeded for {0}", path);
            }, delegate(Exception exception)
            {
                GroupMetricsUtility.Tracer.TraceDebug <string>(0L, "RemoveGroupMetricsDirectory: Unable to remove directory: {0}", exception.Message);
            });
        }
 // Token: 0x06001081 RID: 4225 RVA: 0x0005FFDC File Offset: 0x0005E1DC
 public override void Initialize(RecipientType recipientType)
 {
     base.Initialize(recipientType);
     base.Logger.TraceDebug(null, "Entering GroupMetricsGenerator.Initialize at {0}", new object[]
     {
         DateTime.UtcNow.ToString("o")
     });
     this.taskStartTime = DateTime.UtcNow;
     GroupMetricsUtility.CreateGroupMetricsDirectory();
     GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_GroupMetricsGenerationStarted, null, new object[]
     {
         base.TenantId,
         base.RunId,
         recipientType.ToString()
     });
 }
Exemplo n.º 3
0
 // Token: 0x060010B7 RID: 4279 RVA: 0x000621F8 File Offset: 0x000603F8
 internal static void DeleteDirectory(string path)
 {
     GroupMetricsUtility.TryDiskOperation(delegate
     {
         Directory.Delete(path, true);
     }, delegate(Exception exception)
     {
         if (!(exception is DirectoryNotFoundException))
         {
             GroupMetricsUtility.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToRemoveDirectory, exception.GetType().FullName, new object[]
             {
                 path,
                 exception.GetType().FullName,
                 exception.Message
             });
         }
     });
 }
Exemplo n.º 4
0
 // Token: 0x060010BF RID: 4287 RVA: 0x000624C8 File Offset: 0x000606C8
 public void WriteLine(string line)
 {
     if (this.writer == null)
     {
         this.CreateStreamWriter();
     }
     GroupMetricsUtility.TryDiskOperation(delegate
     {
         this.writer.WriteLine(line);
     }, delegate(Exception exception)
     {
         GroupMetricsUtility.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToWriteFile, exception.GetType().FullName, new object[]
         {
             this.path,
             exception.GetType().FullName,
             exception.Message
         });
         throw new LazyWriterException(exception);
     });
 }
Exemplo n.º 5
0
 // Token: 0x060010C2 RID: 4290 RVA: 0x000625F8 File Offset: 0x000607F8
 private void CreateStreamWriter()
 {
     GroupMetricsUtility.TryDiskOperation(delegate
     {
         string directoryName = Path.GetDirectoryName(this.path);
         Directory.CreateDirectory(directoryName);
         this.writer = new StreamWriter(this.path, false);
         GroupMetricsUtility.Tracer.TraceDebug <string>(0L, "LazyWriter.CreateStreamWriter succeeded: {0}", this.path);
     }, delegate(Exception exception)
     {
         GroupMetricsUtility.Tracer.TraceError <string>(0L, "LazyWriter.CreateStreamWriter failed: {0}", this.path);
         this.writer = null;
         GroupMetricsUtility.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToOpenFile, exception.GetType().FullName, new object[]
         {
             this.path,
             exception.GetType().FullName,
             exception.Message
         });
         throw new LazyWriterException(exception);
     });
 }
Exemplo n.º 6
0
        // Token: 0x060010B2 RID: 4274 RVA: 0x0006209C File Offset: 0x0006029C
        public static bool CreateGroupMetricsDirectory()
        {
            string path = GroupMetricsUtility.GetGroupMetricsDirectoryPath();

            return(GroupMetricsUtility.TryDiskOperation(delegate
            {
                if (GroupMetricsUtility.Fault == GroupMetricsFault.DistributionDirectoryCreationException)
                {
                    throw new IOException("Fault Injection");
                }
                Directory.CreateDirectory(path);
                GroupMetricsUtility.Tracer.TraceDebug <string>(0L, "CreateGroupMetricsDirectory succeeded: {0}", path);
            }, delegate(Exception exception)
            {
                GroupMetricsUtility.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_UnableToCreateGroupMetricsDirectory, null, new object[]
                {
                    path,
                    exception.GetType().FullName,
                    exception.Message
                });
            }));
        }
Exemplo n.º 7
0
        // Token: 0x060010B3 RID: 4275 RVA: 0x000620D8 File Offset: 0x000602D8
        internal static string GetGroupMetricsDirectoryPath()
        {
            string exchangeDirectory = GroupMetricsUtility.GetExchangeDirectory();

            return(Path.Combine(exchangeDirectory, "GroupMetrics"));
        }
Exemplo n.º 8
0
 // Token: 0x060010B5 RID: 4277 RVA: 0x00062114 File Offset: 0x00060314
 internal static ulong GetHash(Guid guid)
 {
     byte[] bytes = guid.ToByteArray();
     return(GroupMetricsUtility.GetHash(bytes));
 }
Exemplo n.º 9
0
        // Token: 0x060010B4 RID: 4276 RVA: 0x000620F8 File Offset: 0x000602F8
        internal static string GetTenantDirectoryPath(OrganizationId organizationId)
        {
            string groupMetricsDirectoryPath = GroupMetricsUtility.GetGroupMetricsDirectoryPath();

            return(GroupMetricsUtility.AppendTenantSubdirectory(groupMetricsDirectoryPath, organizationId));
        }
Exemplo n.º 10
0
        // Token: 0x060010AA RID: 4266 RVA: 0x00061C2C File Offset: 0x0005FE2C
        private Dictionary <Guid, OrganizationId> GetTenantsNeedingGroupMetrics(List <ADUser> systemMailboxes)
        {
            GroupMetricsTenantCache.Tracer.TraceDebug((long)this.GetHashCode(), "DatacenterUMGrammarTenantCache.GetTenantsNeedingGroupMetrics");
            Dictionary <Guid, OrganizationId> dictionary = new Dictionary <Guid, OrganizationId>();

            foreach (ADUser aduser in systemMailboxes)
            {
                if (!GroupMetricsUtility.GroupMetricsEnabledByOrgConfig(aduser.OrganizationId))
                {
                    GroupMetricsTenantCache.Tracer.TraceDebug <Guid, OrganizationId>((long)this.GetHashCode(), "Skipping Mbox='{0}', Organization='{1}' because OrgConfig disables this org's Group Metrics Generation. ", aduser.ExchangeGuid, aduser.OrganizationId);
                }
                else if (!dictionary.ContainsKey(aduser.ExchangeGuid))
                {
                    GroupMetricsTenantCache.Tracer.TraceDebug <Guid, OrganizationId>((long)this.GetHashCode(), "Adding Mbox='{0}', Organization='{1}'", aduser.ExchangeGuid, aduser.OrganizationId);
                    dictionary.Add(aduser.ExchangeGuid, aduser.OrganizationId);
                }
                else
                {
                    GroupMetricsTenantCache.Tracer.TraceDebug <Guid, OrganizationId>((long)this.GetHashCode(), "Skipping Mbox='{0}', Organization='{1}' because Mbox is already included. ", aduser.ExchangeGuid, aduser.OrganizationId);
                }
            }
            if (systemMailboxes.Count > 0 && GroupMetricsUtility.LocalServerMustGenerateGroupMetrics() && GroupMetricsUtility.GroupMetricsEnabledByOrgConfig(OrganizationId.ForestWideOrgId) && !dictionary.ContainsValue(OrganizationId.ForestWideOrgId))
            {
                GroupMetricsTenantCache.Tracer.TraceDebug(0L, "Group metrics generation enabled for First Org by local server config");
                dictionary.Add(Guid.NewGuid(), OrganizationId.ForestWideOrgId);
            }
            return(dictionary);
        }
 // Token: 0x0600107F RID: 4223 RVA: 0x0005FF48 File Offset: 0x0005E148
 public GroupMetricsGenerator(RunData runData, ICollection <DirectoryProcessorMailboxData> mailboxesToProcess) : base(runData)
 {
     this.mailboxesToProcess   = mailboxesToProcess;
     this.tenantDirectory      = GroupMetricsUtility.GetTenantDirectoryPath(base.OrgId);
     this.changedGroupListPath = Path.Combine(this.tenantDirectory, "ChangedGroups.txt");
 }
        // Token: 0x0600108A RID: 4234 RVA: 0x00060890 File Offset: 0x0005EA90
        internal void GetMetricsForSingleGroup(IRecipientSession session, string groupDN, TypedHashSet calculatedGroups, Dictionary <string, object> parentGroupDictionary, IList <string> parentGroupList)
        {
            ADObjectId        id                = new ADObjectId(groupDN);
            ADRawEntry        group             = null;
            ADOperationResult adoperationResult = this.TryRunPerGroupADOperation(delegate
            {
                group = session.ReadADRawEntry(id, GroupMetricsGenerator.groupProperties);
            }, groupDN);

            if (!adoperationResult.Succeeded || group == null)
            {
                return;
            }
            ulong hash = GroupMetricsUtility.GetHash(group.Id.ObjectGuid);

            if (calculatedGroups.Contains(hash))
            {
                return;
            }
            int                  externalMemberCount = 0;
            HashSet <ulong>      allMemberHashes     = new HashSet <ulong>(2000);
            ADRecipientExpansion expander            = new ADRecipientExpansion(session, false);

            adoperationResult = this.TryRunPerGroupADOperation(delegate
            {
                if (GroupMetricsUtility.Fault == GroupMetricsFault.TransientExceptionInExpansion)
                {
                    throw new ADTransientException(new LocalizedString("Fault Injection"));
                }
                if (GroupMetricsUtility.Fault == GroupMetricsFault.InvalidCredentialExceptionInExpansion)
                {
                    throw new ADInvalidCredentialException(new LocalizedString("Fault Injection"));
                }
                if (GroupMetricsUtility.Fault == GroupMetricsFault.PermanentExceptionInExpansion)
                {
                    throw new DataSourceOperationException(new LocalizedString("Fault Injection"));
                }
                expander.Expand(group, delegate(ADRawEntry member, ExpansionType recipientExpansionType, ADRawEntry parent, ExpansionType parentExpansionType)
                {
                    this.RunData.ThrowIfShuttingDown();
                    if (recipientExpansionType == ExpansionType.GroupMembership)
                    {
                        return(ExpansionControl.Continue);
                    }
                    ulong hash2 = GroupMetricsUtility.GetHash(member.Id.ObjectGuid);
                    if (allMemberHashes.TryAdd(hash2) && this.IsExternal(member))
                    {
                        externalMemberCount++;
                    }
                    if (allMemberHashes.Count >= 1000)
                    {
                        return(ExpansionControl.Terminate);
                    }
                    if (recipientExpansionType != ExpansionType.None)
                    {
                        return(ExpansionControl.Skip);
                    }
                    return(ExpansionControl.Continue);
                }, (ExpansionFailure failure, ADRawEntry member, ExpansionType recipientExpansionType, ADRawEntry parent, ExpansionType parentExpansionType) => ExpansionControl.Continue);
            }, groupDN);
            if (!adoperationResult.Succeeded)
            {
                return;
            }
            MultiValuedProperty <ADObjectId> multiValuedProperty = group[ADRecipientSchema.MemberOfGroup] as MultiValuedProperty <ADObjectId>;

            foreach (ADObjectId adobjectId in multiValuedProperty)
            {
                string distinguishedName = adobjectId.DistinguishedName;
                if (!parentGroupDictionary.ContainsKey(distinguishedName))
                {
                    parentGroupDictionary.Add(distinguishedName, null);
                    parentGroupList.Add(distinguishedName);
                }
            }
            int count = allMemberHashes.Count;

            calculatedGroups.Add(hash);
            this.groupsExpanded++;
            int oldValue  = (int)group[ADGroupSchema.GroupMemberCount];
            int oldValue2 = (int)group[ADGroupSchema.GroupExternalMemberCount];

            if (this.ShouldSaveToAD(oldValue, count) || this.ShouldSaveToAD(oldValue2, externalMemberCount))
            {
                this.SaveGroupMetricsToAD(session, group, count, externalMemberCount);
            }
        }