public async Task<IHttpActionResult> RemoveAppFromGroupAsync(string appId, string groupId) { var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AppGroupAssignments); //var ags = new AppGroupAssignmentEntity(appId.ToString(), groupId.ToString()); var result = operation.RetrieveGroupsByAppId(appId.ToString()); return CreateSuccessResult(result); }
public async Task<IHttpActionResult> GetGroupsAsync(string appId) { var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AppGroupAssignments); var result = (IEnumerable<AppGroupAssignmentEntity>)(operation.RetrieveGroupsByAppId(appId)); //var optGroup = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AADGroups); //var final = optGroup.RetrieveGroups(result); return CreateSuccessResult(result); }
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); }
public async Task<IHttpActionResult> AssignAppToGroupAsync(string appId, string groupId,string appName,string groupName) { //var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AppGroupAssignments); //var agse = new AppGroupAssignmentEntity(appId.ToString(), groupId.ToString()); //var result = operation.InsertEntity(agse); //return CreateSuccessResult(result); var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AppGroupAssignments); var appGroupAssignment = new AppGroupAssignmentEntity(appId, groupId); appGroupAssignment.AppName = appName; appGroupAssignment.GroupName = groupName; appGroupAssignment.UpdatedBy = "*****@*****.**"; appGroupAssignment.OperationTypes = OperationTypes.Read.ToString(); var result=operation.InsertEntity(appGroupAssignment); return CreateSuccessResult(result); }
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); }
public async Task<IHttpActionResult> GetUsersAsync(string groupId) { var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.UserGroupAssignments); var result = operation.RetrieveUserGroupAssignments(groupId); return CreateSuccessResult(result); }
public async Task<IHttpActionResult> GetGroupsAsync() { var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AADGroups); var result = operation.RetrieveGroups(); return CreateSuccessResult(result); }
public async Task<IHttpActionResult> GetResourcesByGroupIDAsync(string groupId) { var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.RMResources); var result = operation.RetrieveRMResourcesByGroupID(groupId); return CreateSuccessResult(result); }
public static void TestItaLite() { TableDal userGroupAssignmentOperation = new TableDal(ConfigurationSettings.AppSettings["storageConnection"], TableNames.UserGroupAssignments); TableDal appGroupAssignmentOperation = new TableDal(ConfigurationSettings.AppSettings["storageConnection"], TableNames.AppGroupAssignments); var userGroupAssignment = new UserGroupAssignmentsEntity("8734cc8a-2e67-4a9f-b1aa-3306a5e62760", "f8541113-c54b-4eab-af59-77b0eeef3617"); userGroupAssignment.UserPrincipleName = "*****@*****.**"; userGroupAssignment.GroupName = "MyGroup"; userGroupAssignment.UpdatedBy = "*****@*****.**"; userGroupAssignmentOperation.InsertEntity(userGroupAssignment); var appGroupAssignment = new AppGroupAssignmentEntity("1a7249e7-fa56-4c47-83de-5048097bc510", "f8541113-c54b-4eab-af59-77b0eeef3617"); appGroupAssignment.AppName = "Console App for Azure AD"; appGroupAssignment.GroupName = "MyGroup"; appGroupAssignment.UpdatedBy = "*****@*****.**"; appGroupAssignment.OperationTypes = OperationTypes.Read.ToString(); appGroupAssignmentOperation.InsertEntity(appGroupAssignment); InvokingITA testITACore = new InvokingITA(); // true Console.WriteLine(testITACore.AccessControl(new List<UserGroupAssignmentsEntity>() { userGroupAssignment }, new List<AppGroupAssignmentEntity>() { appGroupAssignment }, "8734cc8a-2e67-4a9f-b1aa-3306a5e62760", "1a7249e7-fa56-4c47-83de-5048097bc510")); // false Console.WriteLine(testITACore.AccessControl(new List<UserGroupAssignmentsEntity>() { userGroupAssignment }, new List<AppGroupAssignmentEntity>() { appGroupAssignment }, "8734cc8a-2e67-4a9f-b1aa-3306a5e62760_", "1a7249e7-fa56-4c47-83de-5048097bc510")); // false Console.WriteLine(testITACore.AccessControl(new List<UserGroupAssignmentsEntity>() { userGroupAssignment }, new List<AppGroupAssignmentEntity>() { appGroupAssignment }, "8734cc8a-2e67-4a9f-b1aa-3306a5e62760", "1a7249e7-fa56-4c47-83de-5048097bc510_")); var userGroupAssignment2 = new UserGroupAssignmentsEntity("8734cc8a-2e67-4a9f-b1aa-3306a5e62760_", "f8541113-c54b-4eab-af59-77b0eeef3617"); userGroupAssignment2.UserPrincipleName = "*****@*****.**"; userGroupAssignment2.GroupName = "MyGroup"; userGroupAssignment2.UpdatedBy = "*****@*****.**"; userGroupAssignmentOperation.InsertEntity(userGroupAssignment2); // true Console.WriteLine(testITACore.AccessControl(new List<UserGroupAssignmentsEntity>() { userGroupAssignment, userGroupAssignment2 }, new List<AppGroupAssignmentEntity>() { appGroupAssignment }, "8734cc8a-2e67-4a9f-b1aa-3306a5e62760_", "1a7249e7-fa56-4c47-83de-5048097bc510")); var appGroupAssignment2 = new AppGroupAssignmentEntity("1a7249e7-fa56-4c47-83de-5048097bc510_", "f8541113-c54b-4eab-af59-77b0eeef3617_"); appGroupAssignment2.AppName = "Console App for Azure AD_"; appGroupAssignment2.GroupName = "MyGroup"; appGroupAssignment2.UpdatedBy = "*****@*****.**"; appGroupAssignment2.OperationTypes = OperationTypes.Read.ToString(); appGroupAssignmentOperation.InsertEntity(appGroupAssignment2); var userGroupAssignment31 = new UserGroupAssignmentsEntity("8734cc8a-2e67-4a9f-b1aa-3306a5e62760", "f8541113-c54b-4eab-af59-77b0eeef3617_"); userGroupAssignment2.UserPrincipleName = "*****@*****.**"; userGroupAssignment2.GroupName = "MyGroup"; userGroupAssignment2.UpdatedBy = "*****@*****.**"; userGroupAssignmentOperation.InsertEntity(userGroupAssignment2); var userGroupAssignment32 = new UserGroupAssignmentsEntity("8734cc8a-2e67-4a9f-b1aa-3306a5e62760_", "f8541113-c54b-4eab-af59-77b0eeef3617_"); userGroupAssignment2.UserPrincipleName = "*****@*****.**"; userGroupAssignment2.GroupName = "MyGroup"; userGroupAssignment2.UpdatedBy = "*****@*****.**"; userGroupAssignmentOperation.InsertEntity(userGroupAssignment2); // true Console.WriteLine(testITACore.AccessControl(new List<UserGroupAssignmentsEntity>() { userGroupAssignment, userGroupAssignment2, userGroupAssignment31 }, new List<AppGroupAssignmentEntity>() { appGroupAssignment, appGroupAssignment2 }, "8734cc8a-2e67-4a9f-b1aa-3306a5e62760", "1a7249e7-fa56-4c47-83de-5048097bc510_")); // true Console.WriteLine(testITACore.AccessControl(new List<UserGroupAssignmentsEntity>() { userGroupAssignment, userGroupAssignment2, userGroupAssignment32 }, new List<AppGroupAssignmentEntity>() { appGroupAssignment, appGroupAssignment2 }, "8734cc8a-2e67-4a9f-b1aa-3306a5e62760_", "1a7249e7-fa56-4c47-83de-5048097bc510_")); }
public async Task<IHttpActionResult> GetUsersAsync(string roleId) { var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.UserAdminRoleAssignments); var result = (IEnumerable<UserAdminRoleAssignmentEntity>)(operation.RetrieveUsersByRoleId(roleId)); return CreateSuccessResult(result); }
public async Task<IHttpActionResult> GetUsersAsync(string userId) { var operation = new TableDal(ConfigurationManager.AppSettings["storageConnection"], TableNames.AADUsers); var result = operation.RetrieveUserByUserId(userId); return CreateSuccessResult(result); }
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); }