c# - 如何以编程方式创建 Azure AD 用户?

标签 c# azure azure-active-directory

我知道有一个 Azure 门户可以管理组、用户等。

是否有任何方法可以以编程方式执行此操作(使用 web-api 或 C# 中的 sdk)?

提前致谢。

最佳答案

使用 Microsoft Graph REST 可以轻松创建 Azure AD 用户。下面是一个代码示例供您引用:

POST https://graph.microsoft.com/v1.0/users 
Authorization: Bearer {token}
Content-type: application/json

{
  "accountEnabled": true,
  "displayName": "displayName-value",
  "mailNickname": "mailNickname-value",
  "userPrincipalName": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="86f3f6e8abf0e7eaf3e3c6f2e3e8e7e8f2abf0e7eaf3e3a8e9e8ebefe5f4e9f5e9e0f2a8e5e9eb" rel="noreferrer noopener nofollow">[email protected]</a>",
  "passwordProfile" : {
    "forceChangePasswordNextSignIn": true,
    "password": "password-value"
  }
}

它还提供了使用 C# 的相应库,来自 here 。有关Microsoft Graph的更多详细信息,您可以引用以下链接:

Overview of Microsoft Graph

Get access tokens to call Microsoft Graph

Create User

关于c# - 如何以编程方式创建 Azure AD 用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44756742/

相关文章:

azure - 注销后,先前捕获的请求在 azure 广告身份验证中仍然有效

c# - 使用 COUNT 进行查询

c# - ASP.NET MVC 上传文件超时

azure - 使用 Python 连接到 Azure Synapse Serverless SQL

azure-active-directory - 尝试更新 'mobilePhone' 时 Microsoft Graph API 权限不足

azure - 具有 Azure AD 域服务的资源组不会被删除

c# - 如何将音频波形绘制到位图

C# WebApiConfig MapHttpRoutes 与 Action AND optional DateTime(-string) AND optional id

azure - 无法成功验证我的网站的 SSL

linux - Azure Cloud shell 始终显示 "command not found"