刪除也是經過ObjectID得到對象進行刪除async
[Authorize] public async Task<ActionResult> Delete(string objectId) { try { ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClient(); var user = (User)await client.Users.GetByObjectId(objectId).ExecuteAsync(); await user.DeleteAsync(); return RedirectToAction("Index"); } catch (Exception exception) { ModelState.AddModelError("", exception.Message); return RedirectToAction("Index"); } }