public void UpdateGroup(GroupInfo groupInfo)
        {
            List <long> groupIds = GetGroupIdsFromNames(groupInfo.Groups),
                        roleIds  = GetRoleIdsFromNames(groupInfo.Roles),
                        vaultIds = GetVaultIdsFromNames(groupInfo.Vaults),
                        userIds  = new List <long>();
            Group group          = FindGroup(groupInfo.Name);

            if (null == group)
            {
                group = ServiceManager.AdminService.AddGroup(groupInfo.Name, AuthenticationType,
                                                             groupInfo.Active, groupInfo.EMail,
                                                             roleIds.Count == 0 ? null : roleIds.ToArray(),
                                                             vaultIds.Count == 0 ? null : vaultIds.ToArray());
            }
            else
            {
                Autodesk.Connectivity.WebServices.GroupInfo currentGroupInfo = ServiceManager.AdminService.GetGroupInfoByGroupId(group.Id);

                if (currentGroupInfo.Users != null)
                {
                    userIds.AddRange(currentGroupInfo.Users.Select(u => u.Id));
                }
            }
            ServiceManager.AdminService.UpdateGroupInfo(group.Id, groupInfo.Name, AuthenticationType,
                                                        groupInfo.EMail, groupInfo.Active,
                                                        roleIds.Count == 0 ? null : roleIds.ToArray(),
                                                        vaultIds.Count == 0 ? null : vaultIds.ToArray(),
                                                        userIds.Count == 0 ? null : userIds.ToArray(),
                                                        groupIds.Count == 0 ? null : groupIds.ToArray());
        }
        public IEnumerable <string> GetGroupNamesForGroup(long groupId)
        {
            List <string> result = new List <string>();

            Autodesk.Connectivity.WebServices.GroupInfo groupInfo = ServiceManager.AdminService.GetGroupInfoByGroupId(groupId);

            if (groupInfo.Groups != null)
            {
                result.AddRange(groupInfo.Groups.Select(g => g.Name));
            }
            return(result);
        }
        private bool IsMemberOfGroup(Group group, User user)
        {
            Autodesk.Connectivity.WebServices.GroupInfo groupInfo = ServiceManager.AdminService.GetGroupInfoByGroupId(group.Id);

            if (null == groupInfo.Users)
            {
                return(false);
            }
            foreach (User tmp in groupInfo.Users)
            {
                if (tmp.Id == user.Id)
                {
                    return(true);
                }
            }
            return(false);
        }
        public string[] GetGroupNamesForUser(long userId)
        {
            List <string> result = new List <string>();

            Group[] groups = ServiceManager.AdminService.GetAllGroups();

            if (null == groups)
            {
                return(result.ToArray());
            }
            foreach (Group group in groups)
            {
                Autodesk.Connectivity.WebServices.GroupInfo groupInfo = ServiceManager.AdminService.GetGroupInfoByGroupId(group.Id);

                if (true == groupInfo.Group.IsSys)
                {
                    continue;
                }
                if (null == groupInfo.Users)
                {
                    continue;
                }
                foreach (User user in groupInfo.Users)
                {
                    if (user.Id != userId)
                    {
                        continue;
                    }
                    if (false == result.Contains(groupInfo.Group.Name))
                    {
                        result.Add(groupInfo.Group.Name);
                    }
                }
            }
            return(result.ToArray());
        }