コード例 #1
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public void RemovePersonFromGroup(RmPerson person, RmGroup group)
        {
            if (!Client.SchemaCached)
            {
                Client.RefreshSchema();
            }

            if (person.ObjectID == null)
            {
                ClientControl.ErrorControl.AddError(new ErrorData(@"Cannot find person object ID"));
                return;
            }

            if (group.ExplicitMember == null)
            {
                ClientControl.ErrorControl.AddError(new ErrorData(@"Cannot load ExplicitMember property of the group"));
                return;
            }

            using (RmResourceChanges transaction = new RmResourceChanges(group))
            {
                if (group.ExplicitMember.Contains(person.ObjectID))
                {
                    transaction.BeginChanges();

                    group.ExplicitMember.Remove(person.ObjectID);
                    Client.Put(transaction);

                    transaction.AcceptChanges();
                }
            }
        }
コード例 #2
0
        public bool HasSharePointGroup(RmPerson person, IList <RmReference> exclusiveGroupId)
        {
            foreach (RmGroup group in Base_GetResourceByAttribute(RmGroup.StaticResourceType(), RmGroup.AttributeNames.ExplicitMember.Name, person.ObjectID.Value,
                                                                  OperationType.Opration_Is, new string[] { RmResource.AttributeNames.ObjectID.Name, RmGroup.AttributeNames.FromSharePoint.Name }))
            {
                if (!group.FromSharePoint)
                {
                    continue;
                }

                if (exclusiveGroupId != null)
                {
                    bool containId = false;
                    foreach (RmReference reference in exclusiveGroupId)
                    {
                        if (reference.Value == group.ObjectID.Value)
                        {
                            containId = true;
                        }
                    }
                    if (!containId)
                    {
                        return(true);
                    }
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        public List <string> GetPermissionGroupBackLink(RmGroup group)
        {
            List <string> retVal = new List <string>();

            foreach (RmRole role in Base_GetResourceByAttribute(RmRole.StaticResourceType(), RmRole.AttributeNames.PremissionRefs.Name, group.ObjectID.Value,
                                                                OperationType.Opration_Is, new string[] { RmResource.AttributeNames.ObjectID.Name }))
            {
                if (role != null)
                {
                    foreach (RmPerson person in Base_GetResourceByAttribute(RmPerson.StaticResourceType(), RmPerson.AttributeNames.RoleRefList.Name,
                                                                            role.ObjectID.Value, OperationType.Opration_Is, new string[] { RmResource.AttributeNames.ObjectID.Name }))
                    {
                        if (person != null)
                        {
                            if (!retVal.Contains(person.ObjectID.Value))
                            {
                                retVal.Add(person.ObjectID.Value);
                            }
                        }
                    }
                }
            }

            return(retVal);
        }
コード例 #4
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public RmResource GetGroupDisplayedOwner(RmGroup group, string[] attributes)
        {
            RmPerson person = Base_GetResourceById(RmPerson.StaticResourceType(), group.DisplayedOwner.Value, attributes) as RmPerson;

            if (person != null)
            {
                return(person);
            }

            return(Base_GetResourceById(RmGroup.StaticResourceType(), group.DisplayedOwner.Value, attributes));
        }
コード例 #5
0
        public List <RmGroup> GetAssignedGroups(RmPerson person, string[] attributes)
        {
            List <RmGroup> retVal = new List <RmGroup>();

            string query = string.Format("[{0}='{1}' or {2}='{3}']",
                                         RmGroup.AttributeNames.ExplicitMember.Name,
                                         person.ObjectID.Value,
                                         RmGroup.AttributeNames.ComputedMember.Name,
                                         person.ObjectID.Value);

            foreach (RmGroup group in Base_GetResourceByQuery(RmGroup.StaticResourceType(), query, attributes))
            {
                if (group != null)
                {
                    retVal.Add(group);
                }
            }

            return(retVal);
        }
コード例 #6
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public List <RmGroup> GetAllGroupWithExplicitMember()
        {
            List <RmGroup> retVal = new List <RmGroup>();

            foreach (RmGroup gp in Base_GetAllResource(RmGroup.StaticResourceType(), new string[] {
                RmResource.AttributeNames.ObjectID.Name,
                RmResource.AttributeNames.DisplayName.Name,
                RmGroup.AttributeNames.ExplicitMember.Name,
                RmGroup.AttributeNames.Filter.Name,
                RmGroup.AttributeNames.FromSharePoint.Name
            }))
            {
                if (gp != null && (gp.Filter == null || gp.Filter == string.Empty))
                {
                    retVal.Add(gp);
                }
            }

            return(retVal);
        }
コード例 #7
0
        public bool ContainsGroup(string ouID, string groupName)
        {
            RmOrgUnit ou = new RmOrgUnit()
            {
                ObjectID = new RmReference(ouID)
            };

            foreach (string objectID in GetAssignedResources(ou))
            {
                RmGroup group = Base_GetResourceById(RmGroup.StaticResourceType(), objectID, new string[] { RmResource.AttributeNames.DisplayName.Name }) as RmGroup;

                if (group != null)
                {
                    if (group.DisplayName.Equals(groupName, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #8
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public List <RmResource> GetGroupExplicitMembers(RmGroup group, string[] attributes)
        {
            List <RmResource> retVal = new List <RmResource>();

            foreach (RmReference memberRef in group.ExplicitMember)
            {
                RmPerson person = Base_GetResourceById(RmPerson.StaticResourceType(), memberRef.Value, attributes) as RmPerson;
                if (person != null)
                {
                    retVal.Add(person);
                    continue;
                }

                RmGroup gp = Base_GetResourceById(RmGroup.StaticResourceType(), memberRef.Value, attributes) as RmGroup;
                if (gp != null)
                {
                    retVal.Add(gp);
                }
            }

            return(retVal);
        }
コード例 #9
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public List <RmRole> GetAssignedRoles(RmGroup group, string[] attributes)
        {
            List <RmRole> retVal = new List <RmRole>();

            foreach (RmUserAssignment assignment in Base_GetResourceByAttribute(
                         RmUserAssignment.StaticResourceType(),
                         RmUserAssignment.AttributeNames.AssignedUser.Name,
                         group.ObjectID.Value,
                         OperationType.Opration_Is,
                         new string[] { RmUserAssignment.AttributeNames.AssignedRole.Name }))
            {
                RmRole role = Base_GetResourceById(RmRole.StaticResourceType(), assignment.AssignedRole.Value, attributes) as RmRole;

                if (role != null)
                {
                    if (!retVal.Any(r => r.ObjectID.Value == role.ObjectID.Value))
                    {
                        retVal.Add(role);
                    }
                }
            }

            return(retVal);
        }
コード例 #10
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public List <RmGroup> GetGroupByQuery(string query, string[] attributes)
        {
            List <RmResource> resourceList = Base_GetResourceByQuery(RmGroup.StaticResourceType(), query, attributes);

            return(resourceList.ConvertAll <RmGroup>(delegate(RmResource r) { return r as RmGroup; }));
        }
コード例 #11
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public List <RmGroup> GetGroupByAttribute(string attributeName, string value, OperationType operation, string[] attributes)
        {
            List <RmResource> resourceList = Base_GetResourceByAttribute(RmGroup.StaticResourceType(), attributeName, value, operation, attributes);

            return(resourceList.ConvertAll <RmGroup>(delegate(RmResource r) { return r as RmGroup; }));
        }
コード例 #12
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
 public RmGroup GetGroupById(string objectId, string[] attributes)
 {
     return(Base_GetResourceById(RmGroup.StaticResourceType(), objectId, attributes) as RmGroup);
 }
コード例 #13
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
 public RmGroup GetGroupByDisplayName(string displayName, string[] attributes)
 {
     return(Base_GetResourceByDisplayName(RmGroup.StaticResourceType(), displayName, attributes) as RmGroup);
 }
コード例 #14
0
ファイル: GroupControl.cs プロジェクト: sagius-li/Lydia
        public List <RmGroup> GetAllGroup(string[] attributes)
        {
            List <RmResource> resourceList = Base_GetAllResource(RmGroup.StaticResourceType(), attributes);

            return(resourceList.ConvertAll <RmGroup>(delegate(RmResource r) { return r as RmGroup; }));
        }