Exemplo n.º 1
0
        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();
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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; }));
        }
Exemplo n.º 11
0
        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; }));
        }
Exemplo n.º 12
0
 public RmGroup GetGroupById(string objectId, string[] attributes)
 {
     return(Base_GetResourceById(RmGroup.StaticResourceType(), objectId, attributes) as RmGroup);
 }
Exemplo n.º 13
0
 public RmGroup GetGroupByDisplayName(string displayName, string[] attributes)
 {
     return(Base_GetResourceByDisplayName(RmGroup.StaticResourceType(), displayName, attributes) as RmGroup);
 }
Exemplo n.º 14
0
        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; }));
        }