[英]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.