我尝试使用Microsoft Graph API创建来宾用户。我使用了属性INSERT INTO TEMP_TBL(
VALUE_SEC,
COUNTRY_CD,
NSB_DEPARTMENT,
EMPLOYEE_RK,
ACCESS_DAY,
ACCESS_TIME,
)
SELECT COUNT(ea.employee_rk) AS no_logins,
ea.country_cd,
ea.nsb_department,
ea.employee_id,
NULL,
NULL
FROM ...
。
UserType
但回复显示user.UserType = "Guest";
。
我可以在门户网站中创建相同的用户。
答案 0 :(得分:1)
要向组织添加外部用户,我们需要使用邀请REST而不是直接创建用户。以下是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;