Пример #1
0
        public void HandleGroupDeletedEvent(ExSearchResultEntry entry)
        {
            if (EhfAdminAccountSynchronizer.IsEventForDeletedOrganization(entry, base.DiagSession))
            {
                throw new InvalidOperationException("Change entry " + entry.DistinguishedName + " is for a deleted organization. The entry should have been ignored from PreDecorate.");
            }
            EhfAdminSyncChangeBuilder adminBuilderForChange = this.GetAdminBuilderForChange(entry);

            base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Encountered a DELETE rolegroup event. ObjectGuid: <{0}>; Company: <{1}>", new object[]
            {
                entry.GetObjectGuid(),
                adminBuilderForChange.TenantOU
            });
            if (adminBuilderForChange != null)
            {
                adminBuilderForChange.HandleGroupDeletedEvent(entry);
            }
            if (!EhfWellKnownGroup.IsWellKnownPartnerGroupDN(entry.DistinguishedName))
            {
                return;
            }
            Guid externalDirectoryObjectId;

            if (EhfCompanyAdmins.TryGetExternalDirectoryObjectId(entry, base.DiagSession, out externalDirectoryObjectId))
            {
                this.AddGroupToDeleteGroupsBatch(externalDirectoryObjectId);
                return;
            }
            base.DiagSession.LogAndTraceError("Could not find the ExternalDirectoryObjectId for well known partner group {0}", new object[]
            {
                entry.DistinguishedName
            });
        }
Пример #2
0
        private EhfWellKnownGroup GetMembersOfGroupFromDN(string groupDistinguishedName, bool isPartnerAdminGroup, EdgeSyncDiag diagSession)
        {
            EhfWellKnownGroup ehfWellKnownGroup;

            if (isPartnerAdminGroup)
            {
                ExSearchResultEntry exSearchResultEntry = this.ehfTargetConnection.ADAdapter.ReadObjectEntry(groupDistinguishedName, false, EhfCompanyAdmins.AttributesToFetchFromMembers);
                if (exSearchResultEntry == null)
                {
                    diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Could not find wellknown partner admin group {0}", new object[]
                    {
                        groupDistinguishedName
                    });
                    return(null);
                }
                if (!EhfCompanyAdmins.IsPartnerManagedGroup(exSearchResultEntry, diagSession))
                {
                    diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Found the partner group {0}, but it is no partner Managed", new object[]
                    {
                        groupDistinguishedName
                    });
                    return(null);
                }
                Guid externalDirectoryObjectId;
                if (!EhfCompanyAdmins.TryGetExternalDirectoryObjectId(exSearchResultEntry, diagSession, out externalDirectoryObjectId))
                {
                    return(null);
                }
                ehfWellKnownGroup = new EhfWellKnownGroup(groupDistinguishedName, externalDirectoryObjectId);
            }
            else
            {
                ehfWellKnownGroup = new EhfWellKnownGroup(groupDistinguishedName);
            }
            Stack <string> stack = new Stack <string>();

            stack.Push(groupDistinguishedName);
            while (stack.Count != 0)
            {
                string text  = stack.Pop();
                string query = string.Format("(memberOf={0})", text);
                diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.High, "Expanding group {0}", new object[]
                {
                    text
                });
                IEnumerable <ExSearchResultEntry> enumerable = this.ehfTargetConnection.ADAdapter.PagedScan(this.tenantOU, query, EhfCompanyAdmins.AttributesToFetchFromMembers);
                int num = 0;
                foreach (ExSearchResultEntry exSearchResultEntry2 in enumerable)
                {
                    num++;
                    if (!exSearchResultEntry2.IsDeleted)
                    {
                        Guid objectGuid = exSearchResultEntry2.GetObjectGuid();
                        if (EhfCompanyAdmins.IsGroup(exSearchResultEntry2))
                        {
                            Guid partnerGroupGuid;
                            if (ehfWellKnownGroup.SubGroups.ContainsKey(objectGuid) || ehfWellKnownGroup.LinkedRoleGroups.ContainsKey(objectGuid))
                            {
                                this.ehfTargetConnection.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "Group {0} is already processed. Ignoring it.", new object[]
                                {
                                    exSearchResultEntry2.DistinguishedName
                                });
                            }
                            else if (EhfCompanyAdmins.IsPartnerManagedLinkedRoleGroup(exSearchResultEntry2, diagSession, out partnerGroupGuid))
                            {
                                ehfWellKnownGroup.LinkedRoleGroups.Add(objectGuid, new PartnerGroupAdminSyncUser(exSearchResultEntry2.DistinguishedName, objectGuid, partnerGroupGuid));
                            }
                            else
                            {
                                ehfWellKnownGroup.SubGroups.Add(objectGuid, new AdminSyncUser(exSearchResultEntry2.DistinguishedName, objectGuid));
                                stack.Push(exSearchResultEntry2.DistinguishedName);
                            }
                        }
                        else
                        {
                            string text2 = string.Empty;
                            if (exSearchResultEntry2.Attributes.ContainsKey("msExchWindowsLiveID") && exSearchResultEntry2.Attributes["msExchWindowsLiveID"].Count != 0)
                            {
                                text2 = (string)exSearchResultEntry2.Attributes["msExchWindowsLiveID"][0];
                                if (text2 != null)
                                {
                                    text2 = text2.Trim();
                                }
                            }
                            else
                            {
                                diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "WindowsLiveID is not set for {0}", new object[]
                                {
                                    exSearchResultEntry2.DistinguishedName
                                });
                            }
                            if (!ehfWellKnownGroup.GroupMembers.ContainsKey(objectGuid))
                            {
                                ehfWellKnownGroup.GroupMembers.Add(objectGuid, new MailboxAdminSyncUser(text2, objectGuid, exSearchResultEntry2.DistinguishedName));
                            }
                        }
                    }
                    else
                    {
                        diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Medium, "{0} is deleted, ignoring...", new object[]
                        {
                            exSearchResultEntry2.DistinguishedName
                        });
                    }
                }
                diagSession.Tracer.TraceDebug <string, int>((long)this.GetHashCode(), "Expanded group {0}. Found {1} children", text, num);
            }
            return(ehfWellKnownGroup);
        }