public async Task<IHttpActionResult> GetRolesByResGroupIDAsync(string resGroupID)
        {
            string groupName = resGroupID.Split(';')[0];
            string groupID = resGroupID.Split(';')[1];
            List<ResourcePageView> list = new List<ResourcePageView>();

            groupID = groupID.Replace("/", "&");

            //RetrieveRMResourcesByGroupID
            var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RMResourceGroups);
            var result = operation.RetrieveRMGroup(groupName);
            foreach (RMResourceGroupEntiry resGroupEntiry in result)
            {
                operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RGRBACRoleAssignments);
                var RGBACRole_result = operation.RetrieveRGRBACRoleAssignmentByGroupID(groupID);
                foreach (RGRBACRoleAssignmentEntity entry in RGBACRole_result)
                {
                    var role_operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RBACRoles);
                    var role_result = role_operation.RetrieveRbacRoleByID(entry.RowKey);
                    RBACRoleEntity rbacRole = new RBACRoleEntity();
                    foreach(RBACRoleEntity _temp in role_result)
                    {
                        rbacRole = _temp;
                        break;
                    }
                    operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.UserRBACRoleAssignments);
                    var userRBRole_result = operation.RetrieveUsersByRbacRoleId(entry.RowKey);
                    foreach (UserRBACRoleAssignmentEntity userRBACRoleAssignmentEntity in userRBRole_result)
                    {
                        ResourcePageView view = new ResourcePageView();
                        view.ResourceGroupName = resGroupEntiry.PartitionKey;
                        view.GroupID = resGroupEntiry.resourceGroupID;
                        view.UserID = "External AAD User";
                        view.UserPrincipleName = "External AAD User";
                        view.Location = resGroupEntiry.RowKey;
                        view.RoleName = rbacRole.RowKey;
                        view.RoleID = rbacRole.PartitionKey;
                        var user_operation= new TableDal(ConfigurationManager.AppSettings["storageConnection"],TableNames.AADUsers);
                        var user_result = user_operation.RetrieveUserByUserId(userRBACRoleAssignmentEntity.PartitionKey);
                        foreach(UserEntity userEntity in user_result)
                        {
                            view.UserID = userEntity.PartitionKey;
                            view.UserPrincipleName = userEntity.RowKey;
                            break;
                        }
                        list.Add(view);
                    }
                }
            }




            return CreateSuccessResult(list);
        }
 public async Task<IHttpActionResult> AssignUserToGroupAsync(string userId,string userName ,string groupId,string groupName)
 {
     var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.UserGroupAssignments);
     var ugae = new UserGroupAssignmentsEntity(userId, groupId);
     ugae.UserPrincipleName = userName;
     ugae.GroupName = groupName;
     ugae.UpdatedBy = "*****@*****.**";
     var result = operation.InsertEntity(ugae);
     var resultUser = operation.RetrieveUserByUserId(userId);
     return CreateSuccessResult(resultUser);
 }
예제 #3
0
 public async Task<IHttpActionResult> GetUsersAsync(string userId)
 {
     var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AADUsers);
     var result = operation.RetrieveUserByUserId(userId);
     return CreateSuccessResult(result);
 }