Ejemplo n.º 1
0
        public async Task<IHttpActionResult> GetRMGroupsAsync(string userId)
        {
            #region get RBACRoleBy userID
            List<RBACRoleEntity> RBACRolelist = new List<RBACRoleEntity>();
            var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.UserRBACRoleAssignments);
            var result = operation.RetrieveRolesByUserId(userId);
            foreach (UserRBACRoleAssignmentEntity entiry in result)
            {
                string roleId = entiry.RowKey;
                operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RBACRoles);
                var RBAC_result = operation.RetrieveRbacRoleByID(roleId);
                foreach (RBACRoleEntity rb_entity in RBAC_result)
                {
                    RBACRolelist.Add(rb_entity);
                }
            }

            #endregion


            List<RmAccessGroupView> list = new List<RmAccessGroupView>();

            foreach (RBACRoleEntity rbacRole in RBACRolelist)
            {
                string roleId = rbacRole.PartitionKey;
                string roleName = rbacRole.RowKey;
                operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RGRBACRoleAssignments);
                var RGresult = operation.RetrieveRMGroupsByRbacRoleId(roleId);
                foreach (RGRBACRoleAssignmentEntity RG_entity in RGresult)
                {
                    string rmGroupName = RG_entity.PartitionKey.Substring(RG_entity.PartitionKey.LastIndexOf("&") + 1);
                    operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RMResourceGroups);
                    var RMresult = operation.RetrieveRMGroup(rmGroupName);
                    foreach (RMResourceGroupEntiry RmG_entity in RMresult)
                    {
                        list.Add(new RmAccessGroupView(RmG_entity, roleName));
                    }
                }

            }
            return CreateSuccessResult(list);
        }
Ejemplo n.º 2
0
        public async Task<IHttpActionResult> GetRBACRolesByUserID(string userId)
        {
            List<RBACRoleEntity> list = new List<RBACRoleEntity>();

            var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.UserRBACRoleAssignments);
            var result = operation.RetrieveRolesByUserId(userId);
            foreach(UserRBACRoleAssignmentEntity entiry in result)
            {
                string roleId = entiry.RowKey;
                operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RBACRoles);
                var RBAC_result = operation.RetrieveRbacRoleByID(roleId);
                foreach(RBACRoleEntity rb_entity in RBAC_result)
                {
                    list.Add(rb_entity);
                }
            }

            return CreateSuccessResult(list);
        }