2
A
回答
3
使用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": "[email protected]",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "password-value"
}
}
它還提供了使用C#從here相應的庫。關於微軟圖表的更多細節,你可以參考以下鏈接:
0
使用C#和圖形API庫薛飛提到的,你可以寫這樣的代碼:
User newUser = new User
{
Id = user.Id,
BusinessPhones = someUser.BusinessPhones,
DisplayName = someUser.DisplayName,
GivenName = someUser.GivenName,
JobTitle = someUser.JobTitle,
Mail = someUser.Mail,
MobilePhone = someUser.MobilePhone,
OfficeLocation = someUser.OfficeLocation,
PreferredLanguage = someUser.PreferredLanguage,
Surname = someUser.Surname,
UserPrincipalName = someUser.UserPrincipalName
};
User createdUser = await graphClient.Users.Request().AddAsync(newUser);
用戶是Graph包提供的類。 graphClient對象是一個提供連接和認證信息的GraphServiceClient對象。
另外,還有一組支持的用戶信息。您可以在對用戶文檔中的Create User示例的回覆中看到它們。文檔中列出了用戶的其他屬性,但這些「屬於」SharePoint,Office 365等應用程序,並且在沒有該應用程序的許可證的情況下不可用。
請注意,文檔是稀疏的,所以有時需要試驗和錯誤才能正常工作。
我一直在使用Graph Snippets example來獲得這方面的經驗。它有很多使用示例。另一個很好的資源是圖形瀏覽器,它可以讓你實時進行實驗。
如果您遇到問題,我會被告知Azure和Graph開發人員對SO進行監控,並對問題做出快速響應。這是我迄今的經驗。
祝你好運!
相關問題
- 1. 以編程方式創建使用C的Azure AD用戶#
- 2. 如何以編程方式在Azure中創建應用程序AD
- 3. 以編程方式在C#中創建Azure AD
- 4. 以編程方式創建Azure緩存
- 5. Wordpress,以編程方式創建用戶
- 6. 以編程方式在Azure上註冊應用程序AD
- 7. 如何以編程方式創建DSN?
- 8. 如何以編程方式創建UIViewController?
- 9. 如何以編程方式創建UIScrollView?
- 10. 如何以編程方式使用django_social_auth創建用戶?
- 11. 以編程方式創建Outlook帳戶
- 12. 如何以編程方式創建ProgressBar?
- 13. 如何以編程方式創建dojo.mobile.view?
- 14. 如何以編程方式創建NSSearchField?
- 15. 如何以編程方式創建JPEG
- 16. 如何以編程方式創建UISplitViewController?
- 17. 如何以編程方式創建CustomCell?
- 18. 如何以編程方式創建UIButton
- 19. 如何以編程方式創建GPO?
- 20. 如何以編程方式創建NSFetchedPropertyDescription?
- 21. 如何以編程方式創建Tabbar
- 22. 如何以編程方式創建SplitView?
- 23. 如何以編程方式創建NSPopover
- 24. 如何以編程方式創建DrawerLayout
- 25. 如何以編程方式創建dojox.mobile.TabBar?
- 26. 如何以編程方式創建UIScrollview
- 27. 如何以編程方式創建UICollectionViewCell
- 28. 如何以編程方式創建BasicHttpBinding?
- 29. 如何以編程方式創建NSTextField?
- 30. 如何以編程方式創建TextView?
我正在開發一個web應用程序,並在後端使用dotnet核心webapi。我有一個UsersController並希望使用該控制器上的端點來獲取有關AzureAD中的用戶的信息。端點是'/ api/users?id = {id}'我如何將請求重定向到'https:// graph.microsoft.com/v1.0/users'?授權中的令牌:持證人{令牌}當前登錄用戶的令牌?或者它是我的應用程序更普遍的標誌?我的網絡應用程序也在Azure中託管。我需要添加Microsoft Graph嗎? – kanpeki
如果您只想獲取當前用戶登錄的特定用戶信息,則可以獲取用戶的委託令牌。你是什麼意思重定向請求?要獲取當前用戶的用戶信息,可以參考[active-directory-dotnet-graphapi-web](https://github.com/Azure-Samples/active-directory-dotnet-graphapi-web)。 –