简体   繁体   English

创建 Azure AD 用户时如何使用 GO SDK?

[英]How to work with GO SDK while Azure AD user creation?

Would like to create Azure AD user from GO SDK programmatically but can't find any related docs.想以编程方式从 GO SDK 创建 Azure AD 用户,但找不到任何相关文档。 I am new to this platform.我是这个平台的新手。

From Azure Portal I know how to create user, but the requirement is do it from GO.从 Azure 门户我知道如何创建用户,但要求是从 GO 中完成。

Anyone tried and got the results?有人试过并得到结果吗? Can someone help with sample GO code?有人可以帮助提供示例 GO 代码吗?

To create user from GO SDK, you can make use of below sample code as mentioned in this MsDoc :要从 GO SDK 创建用户,您可以使用此MsDoc中提到的以下示例代码:

//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY

graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)

requestBody := msgraphsdk.NewUser()
accountEnabled := true
requestBody.SetAccountEnabled(&accountEnabled)
displayName := "User1"
requestBody.SetDisplayName(&displayName)
mailNickname := "test"
requestBody.SetMailNickname(&mailNickname)
userPrincipalName := "user1@contoso.onmicrosoft.com"
requestBody.SetUserPrincipalName(&userPrincipalName)
passwordProfile := msgraphsdk.NewPasswordProfile()
requestBody.SetPasswordProfile(passwordProfile)
forceChangePasswordNextSignIn := true
passwordProfile.SetForceChangePasswordNextSignIn(&forceChangePasswordNextSignIn)
password := "*********"
passwordProfile.SetPassword(&password)
result, err := graphClient.Users().Post(requestBody)

To know how to integrate GO SDK with Azure Ad you can refer below link:要了解如何将 GO SDK 与 Azure Ad 集成,您可以参考以下链接:

Install a Microsoft Graph SDK - Microsoft Graph | 安装 Microsoft Graph SDK - Microsoft Graph | Microsoft Docs 微软文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Go SDK 在 Azure AD 中创建新组? - How to create a new group in Azure AD using Go SDK? 无法通过 azure-sdk-for-go 从 azure 广告中获取应用程序域 - Can not get application domains from azure ad via azure-sdk-for-go Azure AD Go SDK 守护程序应用程序列表用户返回“访问令牌丢失或格式错误” - Azure AD Go SDK daemon application list users returns “Access Token missing or malformed” 如何从 Go 中的 Azure AD 获取 OAuth2.0 令牌? - How to acquire OAuth2.0 token from Azure AD in Go? 如何通过Firestore Go SDK验证用户身份? - How to authenticate user to Firestore Go SDK? 如何使用 Go Google SDK 模拟用户? - How to impersonate user using Go Google SDK? 如何将 IAM 用户凭证与 Go AWS SDK v2 一起使用 - How to use IAM User credentials with Go AWS SDK v2 Go SDK的API调用中需要进行哪些更改以使其适用于Azure Govcloud - What are the changes necessary to be made in the Go SDK's API calls to make it work for Azure Govcloud 更新Azure-SDK-for-go库相关性 - Uppdating azure-sdk-for-go library dependancies Azure Go SDK 用于停止实例并重新启动它 - Azure Go SDK for stopping an instance and restarting it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM