synchronizationJob: validateCredentials
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
验证凭据在租户中是否有效。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Directory.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Application.ReadWrite.OwnedBy、Directory.ReadWrite.All
HTTP 请求
POST /servicePrincipals/{id}/synchronization/jobs/{id}/validateCredentials
名称
说明
Authorization
Bearer {code}
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数
类型
说明
useSavedCredentials
Boolean
When true , the parameter will be ignored and the previously saved credentials credentials (if any) will be validated instead.
credentials
synchronizationSecretKeyStringValuePair 集合
要验证的凭据。 当参数为 时 useSavedCredentials 忽略 true 。
响应
如果验证成功,此方法将返回 响应 204, No Content 代码。 它不会在响应正文中返回任何内容。
示例
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/servicePrincipals/{id}/synchronization/jobs/{id}/validateCredentials
Content-type: application/json
{
credentials: [
{ key: "UserName", value: "user@domain.com" },
{ key: "Password", value: "password-value" }
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var credentials = new List<SynchronizationSecretKeyStringValuePair>()
{
new SynchronizationSecretKeyStringValuePair
{
Key = SynchronizationSecret.UserName,
Value = "user@domain.com"
},
new SynchronizationSecretKeyStringValuePair
{
Key = SynchronizationSecret.Password,
Value = "password-value"
}
};
await graphClient.ServicePrincipals["{servicePrincipal-id}"].Synchronization.Jobs["{synchronizationJob-id}"]
.ValidateCredentials(null,null,null,credentials)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const validateCredentials = {
credentials: [
{ key: 'UserName', value: 'user@domain.com' },
{ key: 'Password', value: 'password-value' }
]
};
await client.api('/servicePrincipals/{id}/synchronization/jobs/{id}/validateCredentials')
.version('beta')
.post(validateCredentials);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/servicePrincipals/{id}/synchronization/jobs/{id}/validateCredentials"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSMutableArray *credentialsList = [[NSMutableArray alloc] init];
MSGraphSynchronizationSecretKeyStringValuePair *credentials = [[MSGraphSynchronizationSecretKeyStringValuePair alloc] init];
[credentials setKey: [MSGraphSynchronizationSecret UserName]];
[credentials setValue:@"user@domain.com"];
[credentialsList addObject: credentials];
MSGraphSynchronizationSecretKeyStringValuePair *credentials = [[MSGraphSynchronizationSecretKeyStringValuePair alloc] init];
[credentials setKey: [MSGraphSynchronizationSecret Password]];
[credentials setValue:@"password-value"];
[credentialsList addObject: credentials];
payloadDictionary[@"credentials"] = credentialsList;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<SynchronizationSecretKeyStringValuePair> credentialsList = new LinkedList<SynchronizationSecretKeyStringValuePair>();
SynchronizationSecretKeyStringValuePair credentials = new SynchronizationSecretKeyStringValuePair();
credentials.key = SynchronizationSecret.USER_NAME;
credentials.value = "user@domain.com";
credentialsList.add(credentials);
SynchronizationSecretKeyStringValuePair credentials1 = new SynchronizationSecretKeyStringValuePair();
credentials1.key = SynchronizationSecret.PASSWORD;
credentials1.value = "password-value";
credentialsList.add(credentials1);
graphClient.servicePrincipals("{id}").synchronization().jobs("{id}")
.validateCredentials(SynchronizationJobValidateCredentialsParameterSet
.newBuilder()
.withApplicationIdentifier(null)
.withTemplateId(null)
.withUseSavedCredentials(null)
.withCredentials(credentialsList)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
servicePrincipalId := "servicePrincipal-id"
synchronizationJobId := "synchronizationJob-id"
graphClient.ServicePrincipalsById(&servicePrincipalId).Synchronization().JobsById(&synchronizationJobId).ValidateCredentials(servicePrincipal-id, synchronizationJob-id).Post()
响应
下面展示了示例响应。
HTTP/1.1 204 No Content