Exemple #1
0
        private async Task ApplyMembership(string csentryDN, string groupid, IList <string> members, IList <string> owners)
        {
            if (members.Count > 0)
            {
                logger.Trace($"{csentryDN}: Adding {members.Count} members");
                await GraphHelperGroups.AddGroupMembers(this.client, groupid, members, true, this.token);
            }

            if (owners.Count > 0)
            {
                logger.Trace($"{csentryDN}: Adding {owners.Count} owners");
                await GraphHelperGroups.AddGroupOwners(this.client, groupid, owners, true, this.token);
            }
        }
        private async Task ProcessDeferredMembership(IList <string> deferredMembers, Group result, IList <string> deferredOwners, string csentryDN)
        {
            bool success = false;

            while (!success)
            {
                if (deferredMembers.Count > 0)
                {
                    logger.Trace($"{csentryDN}: Adding {deferredMembers.Count} deferred members");
                    await GraphHelperGroups.AddGroupMembers(this.client, result.Id, deferredMembers, true, this.token);
                }

                if (deferredOwners.Count > 0)
                {
                    logger.Trace($"{csentryDN}: Adding {deferredOwners.Count} deferred owners");
                    await GraphHelperGroups.AddGroupOwners(this.client, result.Id, deferredOwners, true, this.token);
                }

                success = true;
            }
        }
        private async Task PutAttributeChangeMembers(CSEntryChange c, AttributeChange change)
        {
            IList <string> valueDeletes = change.GetValueDeletes <string>();
            IList <string> valueAdds    = change.GetValueAdds <string>();

            if (change.ModificationType == AttributeModificationType.Delete)
            {
                if (change.Name == "member")
                {
                    List <DirectoryObject> result = await GraphHelperGroups.GetGroupMembers(this.client, c.DN, this.token);

                    valueDeletes = result.Where(u => !this.userFilter.ShouldExclude(u.Id, this.token)).Select(t => t.Id).ToList();
                }
                else
                {
                    List <DirectoryObject> result = await GraphHelperGroups.GetGroupOwners(this.client, c.DN, this.token);

                    valueDeletes = result.Where(u => !this.userFilter.ShouldExclude(u.Id, this.token)).Select(t => t.Id).ToList();
                }
            }

            if (change.Name == "member")
            {
                await GraphHelperGroups.AddGroupMembers(this.client, c.DN, valueAdds, true, this.token);

                await GraphHelperGroups.RemoveGroupMembers(this.client, c.DN, valueDeletes, true, this.token);

                logger.Info($"Membership modification for group {c.DN} completed. Members added: {valueAdds.Count}, members removed: {valueDeletes.Count}");
            }
            else
            {
                await GraphHelperGroups.AddGroupOwners(this.client, c.DN, valueAdds, true, this.token);

                await GraphHelperGroups.RemoveGroupOwners(this.client, c.DN, valueDeletes, true, this.token);

                logger.Info($"Owner modification for group {c.DN} completed. Owners added: {valueAdds.Count}, owners removed: {valueDeletes.Count}");
            }
        }