I am using the following code. The code executes fine but does not delete the user.
IUser deleteuser = new User();
deleteuser = users.Where(myuser => myuse
r.MailNickname.Equals("IshanArora")).FirstOrDefault();
if (deleteuser != null)
{
deleteuser.DeleteAsync();
}
I am deleting users by retrieving it before deleting it:
private async Task DeleteUser()
{
ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClient();
// Retrieve user from its displayname
var user = await client.Users.Where(u => u.DisplayName == "user two").ExecuteSingleAsync();
// Or Retrieve user from its principal name
// var user = await client.Users.Where(u => u.UserPrincipalName== "user two").ExecuteSingleAsync();
// Or Retrieve user from its id in the directory
//var user = await client.Users.GetByObjectId("0b34c995-0970-4776-ae87-f66d384f9c45").ExecuteAsync();
// Delete the user
await user.DeleteAsync();
}
You should notice that it may takes few seconds before seeing that the user is deleted from the Azure portal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With