/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); CustomerUser user = GetUserById(CustomerId, UserId); try { UserMember newMember = new UserMember() { UserPrincipalName = user.UserPrincipalName, DisplayName = user.DisplayName, Id = user.Id }; Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers.Create(newMember); WriteObject(true); } catch (PSPartnerException ex) { throw new PSPartnerException($"Error adding user {UserId} to role {RoleId}", ex); } finally { user = null; } }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { CustomerId.AssertNotEmpty(nameof(CustomerId)); UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers[UserId].DeleteAsync().ConfigureAwait(false).GetAwaiter().GetResult(); WriteObject(true); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { CustomerId.AssertNotEmpty(nameof(CustomerId)); UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); try { Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers[UserId].Delete(); WriteObject(true); } catch (PSPartnerException ex) { throw new PSPartnerException("Error removing user " + UserId + "from role " + RoleId, ex); } }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); CustomerUser user = GetUserById(CustomerId, UserId); UserMember newMember = new UserMember() { UserPrincipalName = user.UserPrincipalName, DisplayName = user.DisplayName, Id = user.Id }; Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers.CreateAsync(newMember).GetAwaiter().GetResult(); WriteObject(true); }