我使用以下代码从Azure活动目录B2C中删除用户。
Uri servicePointUri = new Uri("https://graph.windows.net");
Uri serviceRoot = new Uri(servicePointUri, "xxxx.onmicrosoft.com");
var activeDirectoryClient = new ActiveDirectoryClient(serviceRoot, async () => await GetAccessToken());
var myUser = new Microsoft.Azure.ActiveDirectory.GraphClient.User()
{
ObjectId = "63ca9c1d-2bd0-4a6b-8bf6-b850b16ed50b"
};
await myUser.DeleteAsync();
但我最终得到了异常消息"未初始化"。
有人可以告诉我这是什么问题吗?
答案 0 :(得分:2)
您可能必须首先检索要删除的用户。 E. g。:
var user = await Client.Users.Where(u => u.ObjectId.Equals("63ca9c1d-2bd0-4a6b-8bf6-b850b16ed50b"))).ExecuteSingleAsync();
await user.DeleteAsync();