无法使用GraphServiceClient - ASP.NET MVC更新Azure Active Directory B2C用户

时间:2018-02-10 17:49:45

标签: c# asp.net-mvc azure microsoft-graph azure-ad-b2c

我正在尝试创建然后更新Azure Active Directory B2C用户的个人资料。以下是我在Create User instructions之后创建用户个人资料的方式,该资料正常运行:

 User newGuestUser = await graphClient.Users.Request().AddAsync(new User
 {
     AccountEnabled = true,
     DisplayName = guestUserProfile.Name,
     MailNickname = guestUserProfile.Organization,
     UserPrincipalName = guestUserProfile.Username + '@' + domain,
     UserType = "Guest",
     PasswordProfile = new PasswordProfile
     {
         Password = new NetworkCredential(string.Empty, guestUserProfile.Password).Password,
         ForceChangePasswordNextSignIn = true
     }
 });

然后,我尝试更新用户,例如,添加用户" City"在Update User instructions之后。

 // Update the user.
 await graphClient.Users[newGuestUser.Id].Request().UpdateAsync(new User
 {
      City = "Los Angeles",
      State = "CA"
 });

然而,当我使用下面的代码获取用户对象时," City"字段为空?为什么是这样?我怎样才能得到#34; City"领域说"洛杉矶"?

 newGuestUser = await graphClient.Users[newGuestUser.Id].Request().GetAsync();

另外,仅供参考,我的graphClient资源ID为https://graph.microsoft.com

查看Get User instructions,我需要使用$select语句。我如何使用graphClient执行此操作?

1 个答案:

答案 0 :(得分:0)

查看Get User instructions,我需要使用raise NotFound('User Message', code=500) 语句。

$select