命名空间:microsoft.graph
重要
Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
将经过外部身份验证的用户转换为内部用户。 用户能够以内部用户身份登录到主机租户,并能够以成员身份访问资源。 有关此转换的详细信息,请参阅 将外部用户转换为内部用户。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
✅ |
✅ |
✅ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
User-ConvertToInternal.ReadWrite.All |
User.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
| 应用程序 |
User-ConvertToInternal.ReadWrite.All |
User.ReadWrite.All |
重要
在具有工作或学校帐户的委托方案中,必须为登录用户分配受支持的Microsoft Entra角色或具有支持的角色权限的自定义角色。
用户管理员 是此作支持的最低特权角色。
HTTP 请求
POST /users/{usersId}/convertExternalToInternalMemberUser
| 名称 |
说明 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| Content-Type |
application/json. 必需。 |
请求正文
在请求正文中,提供参数的 JSON 表示形式。
下表列出了调用此作时所需的参数。
| 参数 |
类型 |
说明 |
| mail |
String |
可选。 |
| passwordProfile |
passwordProfile |
对于在云中管理其身份验证的用户是必需的。 |
| userPrincipalName |
String |
云用户需要更改 userPrincipalName。 本地同步用户不需要,因为其 userPrincipalName 在本地托管。 |
响应
如果成功,此方法将 200 OK 返回响应代码和 conversionUserDetails 响应对象。
示例
示例 1:转换云用户并要求他们在下次登录时重置密码
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/users/0b8cc234-ef87-4015-9785-cbb42000d41c/convertExternalToInternalMemberUser
Content-type: application/json
{
"userPrincipalName": "AdeleVance@contoso.com",
"passwordProfile": {
"password": "Zdi087#2jhkahf",
"forceChangePasswordNextSignIn": "true"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.ConvertExternalToInternalMemberUser;
using Microsoft.Graph.Beta.Models;
var requestBody = new ConvertExternalToInternalMemberUserPostRequestBody
{
UserPrincipalName = "AdeleVance@contoso.com",
PasswordProfile = new PasswordProfile
{
Password = "Zdi087#2jhkahf",
ForceChangePasswordNextSignIn = true,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].ConvertExternalToInternalMemberUser.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewConvertExternalToInternalMemberUserPostRequestBody()
userPrincipalName := "AdeleVance@contoso.com"
requestBody.SetUserPrincipalName(&userPrincipalName)
passwordProfile := graphmodels.NewPasswordProfile()
password := "Zdi087#2jhkahf"
passwordProfile.SetPassword(&password)
forceChangePasswordNextSignIn := true
passwordProfile.SetForceChangePasswordNextSignIn(&forceChangePasswordNextSignIn)
requestBody.SetPasswordProfile(passwordProfile)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
convertExternalToInternalMemberUser, err := graphClient.Users().ByUserId("user-id").ConvertExternalToInternalMemberUser().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.convertexternaltointernalmemberuser.ConvertExternalToInternalMemberUserPostRequestBody convertExternalToInternalMemberUserPostRequestBody = new com.microsoft.graph.beta.users.item.convertexternaltointernalmemberuser.ConvertExternalToInternalMemberUserPostRequestBody();
convertExternalToInternalMemberUserPostRequestBody.setUserPrincipalName("AdeleVance@contoso.com");
PasswordProfile passwordProfile = new PasswordProfile();
passwordProfile.setPassword("Zdi087#2jhkahf");
passwordProfile.setForceChangePasswordNextSignIn(true);
convertExternalToInternalMemberUserPostRequestBody.setPasswordProfile(passwordProfile);
var result = graphClient.users().byUserId("{user-id}").convertExternalToInternalMemberUser().post(convertExternalToInternalMemberUserPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const conversionUserDetails = {
userPrincipalName: 'AdeleVance@contoso.com',
passwordProfile: {
password: 'Zdi087#2jhkahf',
forceChangePasswordNextSignIn: 'true'
}
};
await client.api('/users/0b8cc234-ef87-4015-9785-cbb42000d41c/convertExternalToInternalMemberUser')
.version('beta')
.post(conversionUserDetails);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\ConvertExternalToInternalMemberUser\ConvertExternalToInternalMemberUserPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PasswordProfile;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ConvertExternalToInternalMemberUserPostRequestBody();
$requestBody->setUserPrincipalName('AdeleVance@contoso.com');
$passwordProfile = new PasswordProfile();
$passwordProfile->setPassword('Zdi087#2jhkahf');
$passwordProfile->setForceChangePasswordNextSignIn(true);
$requestBody->setPasswordProfile($passwordProfile);
$result = $graphServiceClient->users()->byUserId('user-id')->convertExternalToInternalMemberUser()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Users.Actions
$params = @{
userPrincipalName = "AdeleVance@contoso.com"
passwordProfile = @{
password = "Zdi087#2jhkahf"
forceChangePasswordNextSignIn = "true"
}
}
Convert-MgBetaUserExternalToInternalMemberUser -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.convert_external_to_internal_member_user.convert_external_to_internal_member_user_post_request_body import ConvertExternalToInternalMemberUserPostRequestBody
from msgraph_beta.generated.models.password_profile import PasswordProfile
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ConvertExternalToInternalMemberUserPostRequestBody(
user_principal_name = "AdeleVance@contoso.com",
password_profile = PasswordProfile(
password = "Zdi087#2jhkahf",
force_change_password_next_sign_in = True,
),
)
result = await graph_client.users.by_user_id('user-id').convert_external_to_internal_member_user.post(request_body)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#microsoft.graph.conversionUserDetails",
"displayName": "Adele Vance",
"userPrincipalName": "AdeleVance@contoso.com",
"convertedToInternalUserDateTime": "2024-02-05T20:16:37.5012924Z",
"mail": "AdeleV@woodgrove.com"
}
示例 2:转换云用户、更改其邮件地址,并在下次登录时要求重置密码
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/users/0b8cc234-ef87-4015-9785-cbb42000d41c/convertExternalToInternalMemberUser
Content-type: application/json
{
"userPrincipalName": "AdeleVance@contoso.com",
"passwordProfile": {
"password": "Zdi087#2jhkahf",
"forceChangePasswordNextSignIn": "true"
},
"mail": "AdeleV@contoso.com"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.ConvertExternalToInternalMemberUser;
using Microsoft.Graph.Beta.Models;
var requestBody = new ConvertExternalToInternalMemberUserPostRequestBody
{
UserPrincipalName = "AdeleVance@contoso.com",
PasswordProfile = new PasswordProfile
{
Password = "Zdi087#2jhkahf",
ForceChangePasswordNextSignIn = true,
},
Mail = "AdeleV@contoso.com",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].ConvertExternalToInternalMemberUser.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewConvertExternalToInternalMemberUserPostRequestBody()
userPrincipalName := "AdeleVance@contoso.com"
requestBody.SetUserPrincipalName(&userPrincipalName)
passwordProfile := graphmodels.NewPasswordProfile()
password := "Zdi087#2jhkahf"
passwordProfile.SetPassword(&password)
forceChangePasswordNextSignIn := true
passwordProfile.SetForceChangePasswordNextSignIn(&forceChangePasswordNextSignIn)
requestBody.SetPasswordProfile(passwordProfile)
mail := "AdeleV@contoso.com"
requestBody.SetMail(&mail)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
convertExternalToInternalMemberUser, err := graphClient.Users().ByUserId("user-id").ConvertExternalToInternalMemberUser().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.convertexternaltointernalmemberuser.ConvertExternalToInternalMemberUserPostRequestBody convertExternalToInternalMemberUserPostRequestBody = new com.microsoft.graph.beta.users.item.convertexternaltointernalmemberuser.ConvertExternalToInternalMemberUserPostRequestBody();
convertExternalToInternalMemberUserPostRequestBody.setUserPrincipalName("AdeleVance@contoso.com");
PasswordProfile passwordProfile = new PasswordProfile();
passwordProfile.setPassword("Zdi087#2jhkahf");
passwordProfile.setForceChangePasswordNextSignIn(true);
convertExternalToInternalMemberUserPostRequestBody.setPasswordProfile(passwordProfile);
convertExternalToInternalMemberUserPostRequestBody.setMail("AdeleV@contoso.com");
var result = graphClient.users().byUserId("{user-id}").convertExternalToInternalMemberUser().post(convertExternalToInternalMemberUserPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const conversionUserDetails = {
userPrincipalName: 'AdeleVance@contoso.com',
passwordProfile: {
password: 'Zdi087#2jhkahf',
forceChangePasswordNextSignIn: 'true'
},
mail: 'AdeleV@contoso.com'
};
await client.api('/users/0b8cc234-ef87-4015-9785-cbb42000d41c/convertExternalToInternalMemberUser')
.version('beta')
.post(conversionUserDetails);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\ConvertExternalToInternalMemberUser\ConvertExternalToInternalMemberUserPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\PasswordProfile;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ConvertExternalToInternalMemberUserPostRequestBody();
$requestBody->setUserPrincipalName('AdeleVance@contoso.com');
$passwordProfile = new PasswordProfile();
$passwordProfile->setPassword('Zdi087#2jhkahf');
$passwordProfile->setForceChangePasswordNextSignIn(true);
$requestBody->setPasswordProfile($passwordProfile);
$requestBody->setMail('AdeleV@contoso.com');
$result = $graphServiceClient->users()->byUserId('user-id')->convertExternalToInternalMemberUser()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Users.Actions
$params = @{
userPrincipalName = "AdeleVance@contoso.com"
passwordProfile = @{
password = "Zdi087#2jhkahf"
forceChangePasswordNextSignIn = "true"
}
mail = "AdeleV@contoso.com"
}
Convert-MgBetaUserExternalToInternalMemberUser -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.convert_external_to_internal_member_user.convert_external_to_internal_member_user_post_request_body import ConvertExternalToInternalMemberUserPostRequestBody
from msgraph_beta.generated.models.password_profile import PasswordProfile
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ConvertExternalToInternalMemberUserPostRequestBody(
user_principal_name = "AdeleVance@contoso.com",
password_profile = PasswordProfile(
password = "Zdi087#2jhkahf",
force_change_password_next_sign_in = True,
),
mail = "AdeleV@contoso.com",
)
result = await graph_client.users.by_user_id('user-id').convert_external_to_internal_member_user.post(request_body)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#microsoft.graph.conversionUserDetails",
"displayName": "Adele Vance",
"userPrincipalName": "AdeleVance@contoso.com",
"convertedToInternalUserDateTime": "2024-02-05T20:16:37.5012924Z",
"mail": "AdeleV@woodgrove.com"
}
示例 3:为从本地 AD 同步的用户将外部用户转换为内部用户
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/users/0b8cc234-ef87-4015-9785-cbb42000d41c/convertExternalToInternalMemberUser
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].ConvertExternalToInternalMemberUser.PostAsync(null);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
convertExternalToInternalMemberUser, err := graphClient.Users().ByUserId("user-id").ConvertExternalToInternalMemberUser().Post(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
var result = graphClient.users().byUserId("{user-id}").convertExternalToInternalMemberUser().post(null);
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/users/0b8cc234-ef87-4015-9785-cbb42000d41c/convertExternalToInternalMemberUser')
.version('beta')
.post();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->users()->byUserId('user-id')->convertExternalToInternalMemberUser()->post()->wait();
Import-Module Microsoft.Graph.Beta.Users.Actions
Convert-MgBetaUserExternalToInternalMemberUser -UserId $userId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.users.by_user_id('user-id').convert_external_to_internal_member_user.post(None)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#microsoft.graph.conversionUserDetails",
"displayName": "Adele Vance",
"userPrincipalName": "AdeleVance@contoso.com",
"convertedToInternalUserDateTime": "2024-02-05T20:16:37.5012924Z",
"mail": "AdeleV@woodgrove.com"
}
相关内容