【问题标题】:Delay when adding user添加用户时延迟
【发布时间】:2020-09-29 06:58:03
【问题描述】:

我正在将用户添加到 AAD,然后将用户添加到组。但是,在我们添加用户之前好像有一个小的延迟。是预期的行为吗?如果是,您预计会延迟多长时间?

在下面的代码中,将用户添加到组失败,因为用户为空。几秒钟后,我可以添加它。为了实现这一点,我需要知道预期的延迟是多少。可以是几分钟还是几小时?

var email = "xxx";

var graphClient = await Graph.GraphServiceClientExtension.GetGraphClient( _config.AzureAppIdExternal, _config.AzureAppSecretExternal, _config.TenantNameExternal);

var invite = new Microsoft.Graph.Invitation();
invite.InvitedUserEmailAddress = email;
invite.InvitedUserDisplayName = email;

invite.InviteRedirectUrl = "xxx";
invite.SendInvitationMessage = true;

var inviteMsgInfo = new Microsoft.Graph.InvitedUserMessageInfo();
inviteMsgInfo.CustomizedMessageBody = "Velkommen, xx";
invite.InvitedUserMessageInfo = inviteMsgInfo;

var inviteUserResponse = await graphClient.Invitations.Request().AddAsync(invite);
var user = (await graphClient.Users.Request().Filter($"mail eq '{email}'").GetAsync()).FirstOrDefault();

await graphClient.Groups["xx-7b17-4ed7-9b75-xx"].Members.References.Request().AddAsync(user);

【问题讨论】:

    标签: azure-active-directory microsoft-graph-api microsoft-graph-sdks


    【解决方案1】:

    可以确认使用 Azure 添加用户有延迟。总是5-10分钟,但我无法确定延迟的时间。

    检查用户是否已添加似乎更好,然后您可以将其添加到组中。您可以使用 Graph API 并查询您想要的用户,如下所示:

    https://graph.microsoft.com/v1.0/users?$filter=startswith(userPrincipalName,'someuser@mytenant.onmicrosoft.com')
    

    这是一个code sample 供您参考。

    【讨论】:

      猜你喜欢
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      • 2021-08-15
      • 1970-01-01
      • 1970-01-01
      • 2015-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多