Azure active directory 使用Microsoft Graph API在Azure AD中创建来宾用户
我尝试使用Microsoft Graph API创建来宾用户。我使用了属性UserType 但是响应显示无效的用户主体名称Azure active directory 使用Microsoft Graph API在Azure AD中创建来宾用户,azure-active-directory,microsoft-graph-api,Azure Active Directory,Microsoft Graph Api,我尝试使用Microsoft Graph API创建来宾用户。我使用了属性UserType 但是响应显示无效的用户主体名称 我可以在门户中创建相同的用户 要向组织中添加外部用户,我们需要使用邀请REST,而不是直接创建用户。以下是Microsoft Graph SDK的其余部分和代码示例,供您参考: POST https://graph.microsoft.com/v1.0/invitations Content-type: application/json Content-length: 55
我可以在门户中创建相同的用户 要向组织中添加外部用户,我们需要使用邀请REST,而不是直接创建用户。以下是Microsoft Graph SDK的其余部分和代码示例,供您参考:
POST https://graph.microsoft.com/v1.0/invitations
Content-type: application/json
Content-length: 551
{
"invitedUserEmailAddress": "yyy@test.com",
"inviteRedirectUrl": "https://myapp.com"
}
代码示例:
string accessToken = "";
var graphserviceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
(requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
return Task.FromResult(0);
}));
Invitation invitation = new Invitation();
invitation.SendInvitationMessage = true;
invitation.InvitedUserEmailAddress = "xxxx@hotmail.com";
invitation.InviteRedirectUrl = "http://localhost";
var result= graphserviceClient.Invitations.Request().AddAsync(invitation).Result;
要向组织中添加外部用户,我们需要使用邀请REST,而不是直接创建用户。以下是Microsoft Graph SDK的其余部分和代码示例,供您参考:
POST https://graph.microsoft.com/v1.0/invitations
Content-type: application/json
Content-length: 551
{
"invitedUserEmailAddress": "yyy@test.com",
"inviteRedirectUrl": "https://myapp.com"
}
代码示例:
string accessToken = "";
var graphserviceClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
(requestMessage) =>
{
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
return Task.FromResult(0);
}));
Invitation invitation = new Invitation();
invitation.SendInvitationMessage = true;
invitation.InvitedUserEmailAddress = "xxxx@hotmail.com";
invitation.InviteRedirectUrl = "http://localhost";
var result= graphserviceClient.Invitations.Request().AddAsync(invitation).Result;
这里没有足够的东西继续下去。你是如何认证的?您使用的是什么SDK?你用什么来命名userPrincipalName?这里没有足够的内容。你是如何认证的?您使用的是什么SDK?您使用了什么作为userPrincipalName?