コード例 #1
0
        private async Task GroupMemberToCSEntryChange(CSEntryChange c, SchemaType schemaType)
        {
            if (schemaType.Attributes.Contains("member"))
            {
                List <DirectoryObject> members = await GraphHelperGroups.GetGroupMembers(this.client, c.DN, this.token);

                List <object> memberIds = members.Where(u => !this.userFilter.ShouldExclude(u.Id, this.token)).Select(t => t.Id).ToList <object>();

                if (memberIds.Count > 0)
                {
                    c.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("member", memberIds));
                }
            }

            if (schemaType.Attributes.Contains("owner"))
            {
                List <DirectoryObject> owners = await GraphHelperGroups.GetGroupOwners(this.client, c.DN, this.token);

                List <object> ownerIds = owners.Where(u => !this.userFilter.ShouldExclude(u.Id, this.token)).Select(t => t.Id).ToList <object>();

                if (ownerIds.Count > 0)
                {
                    c.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("owner", ownerIds));
                }
            }
        }
コード例 #2
0
        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}");
            }
        }