Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Validate that the credentials are valid in the tenant.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
❌ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Synchronization.ReadWrite.All |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Application.ReadWrite.OwnedBy |
Synchronization.ReadWrite.All |
Important
In delegated scenarios with work or school accounts, the signed-in user must be an owner or member of the group or be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation.
- Application Administrator
- Cloud Application Administrator
- Hybrid Identity Administrator - to configure Microsoft Entra Cloud Sync
HTTP request
POST /servicePrincipals/{id}/synchronization/jobs/{id}/validateCredentials
Request body
In the request body, provide a JSON object with the following parameters.
Parameter |
Type |
Description |
useSavedCredentials |
Boolean |
When true , the credentials parameter will be ignored and the previously saved credentials (if any) will be validated instead. |
credentials |
synchronizationSecretKeyStringValuePair collection |
Credentials to validate. Ignored when the useSavedCredentials parameter is true . |
templateId |
String |
Defines default settings for the provisioning configuration. |
Response
If validation is successful, this method returns a 204, No Content
response code. It doesn't return anything in the response body.
Example
Request
The following example shows a request.
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"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.ServicePrincipals.Item.Synchronization.Jobs.Item.ValidateCredentials;
using Microsoft.Graph.Beta.Models;
var requestBody = new ValidateCredentialsPostRequestBody
{
Credentials = new List<SynchronizationSecretKeyStringValuePair>
{
new SynchronizationSecretKeyStringValuePair
{
Key = SynchronizationSecret.UserName,
Value = "user@domain.com",
},
new SynchronizationSecretKeyStringValuePair
{
Key = SynchronizationSecret.Password,
Value = "password-value",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.ServicePrincipals["{servicePrincipal-id}"].Synchronization.Jobs["{synchronizationJob-id}"].ValidateCredentials.PostAsync(requestBody);
mgc-beta service-principals synchronization jobs validate-credentials-by-id post --service-principal-id {servicePrincipal-id} --synchronization-job-id {synchronizationJob-id} --body '{\
"credentials": [\
{\
"key": "UserName",\
"value": "user@domain.com"\
},\
{\
"key": "Password",\
"value": "password-value"\
}\
]\
}\
'
// 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"
graphserviceprincipals "github.com/microsoftgraph/msgraph-beta-sdk-go/serviceprincipals"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphserviceprincipals.NewValidateCredentialsPostRequestBody()
synchronizationSecretKeyStringValuePair := graphmodels.NewSynchronizationSecretKeyStringValuePair()
key := graphmodels.USERNAME_SYNCHRONIZATIONSECRET
synchronizationSecretKeyStringValuePair.SetKey(&key)
value := "user@domain.com"
synchronizationSecretKeyStringValuePair.SetValue(&value)
synchronizationSecretKeyStringValuePair1 := graphmodels.NewSynchronizationSecretKeyStringValuePair()
key := graphmodels.PASSWORD_SYNCHRONIZATIONSECRET
synchronizationSecretKeyStringValuePair1.SetKey(&key)
value := "password-value"
synchronizationSecretKeyStringValuePair1.SetValue(&value)
credentials := []graphmodels.SynchronizationSecretKeyStringValuePairable {
synchronizationSecretKeyStringValuePair,
synchronizationSecretKeyStringValuePair1,
}
requestBody.SetCredentials(credentials)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.ServicePrincipals().ByServicePrincipalId("servicePrincipal-id").Synchronization().Jobs().BySynchronizationJobId("synchronizationJob-id").ValidateCredentials().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.serviceprincipals.item.synchronization.jobs.item.validatecredentials.ValidateCredentialsPostRequestBody validateCredentialsPostRequestBody = new com.microsoft.graph.beta.serviceprincipals.item.synchronization.jobs.item.validatecredentials.ValidateCredentialsPostRequestBody();
LinkedList<SynchronizationSecretKeyStringValuePair> credentials = new LinkedList<SynchronizationSecretKeyStringValuePair>();
SynchronizationSecretKeyStringValuePair synchronizationSecretKeyStringValuePair = new SynchronizationSecretKeyStringValuePair();
synchronizationSecretKeyStringValuePair.setKey(SynchronizationSecret.UserName);
synchronizationSecretKeyStringValuePair.setValue("user@domain.com");
credentials.add(synchronizationSecretKeyStringValuePair);
SynchronizationSecretKeyStringValuePair synchronizationSecretKeyStringValuePair1 = new SynchronizationSecretKeyStringValuePair();
synchronizationSecretKeyStringValuePair1.setKey(SynchronizationSecret.Password);
synchronizationSecretKeyStringValuePair1.setValue("password-value");
credentials.add(synchronizationSecretKeyStringValuePair1);
validateCredentialsPostRequestBody.setCredentials(credentials);
graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").synchronization().jobs().bySynchronizationJobId("{synchronizationJob-id}").validateCredentials().post(validateCredentialsPostRequestBody);
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);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\ServicePrincipals\Item\Synchronization\Jobs\Item\ValidateCredentials\ValidateCredentialsPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\SynchronizationSecretKeyStringValuePair;
use Microsoft\Graph\Beta\Generated\Models\SynchronizationSecret;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ValidateCredentialsPostRequestBody();
$credentialsSynchronizationSecretKeyStringValuePair1 = new SynchronizationSecretKeyStringValuePair();
$credentialsSynchronizationSecretKeyStringValuePair1->setKey(new SynchronizationSecret('userName'));
$credentialsSynchronizationSecretKeyStringValuePair1->setValue('user@domain.com');
$credentialsArray []= $credentialsSynchronizationSecretKeyStringValuePair1;
$credentialsSynchronizationSecretKeyStringValuePair2 = new SynchronizationSecretKeyStringValuePair();
$credentialsSynchronizationSecretKeyStringValuePair2->setKey(new SynchronizationSecret('password'));
$credentialsSynchronizationSecretKeyStringValuePair2->setValue('password-value');
$credentialsArray []= $credentialsSynchronizationSecretKeyStringValuePair2;
$requestBody->setCredentials($credentialsArray);
$graphServiceClient->servicePrincipals()->byServicePrincipalId('servicePrincipal-id')->synchronization()->jobs()->bySynchronizationJobId('synchronizationJob-id')->validateCredentials()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Applications
$params = @{
credentials = @(
@{
key = "UserName"
value = "user@domain.com"
}
@{
key = "Password"
value = "password-value"
}
)
}
Test-MgBetaServicePrincipalSynchronizationJobCredential -ServicePrincipalId $servicePrincipalId -SynchronizationJobId $synchronizationJobId -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.serviceprincipals.item.synchronization.jobs.item.validate_credentials.validate_credentials_post_request_body import ValidateCredentialsPostRequestBody
from msgraph_beta.generated.models.synchronization_secret_key_string_value_pair import SynchronizationSecretKeyStringValuePair
from msgraph_beta.generated.models.synchronization_secret import SynchronizationSecret
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ValidateCredentialsPostRequestBody(
credentials = [
SynchronizationSecretKeyStringValuePair(
key = SynchronizationSecret.UserName,
value = "user@domain.com",
),
SynchronizationSecretKeyStringValuePair(
key = SynchronizationSecret.Password,
value = "password-value",
),
],
)
await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').synchronization.jobs.by_synchronization_job_id('synchronizationJob-id').validate_credentials.post(request_body)
Response
The following example shows the response.
HTTP/1.1 204 No Content