Как сопоставить AppRoleAssignments с приложениями в «Graph Explorer API» - PullRequest
1 голос
/ 08 апреля 2019

Как сопоставить https://graph.microsoft.com/beta/me/appRoleAssignments с https://graph.microsoft.com/beta/applications.

Какой идентификатор должен совпадать?

Как сравнить эти два кода JSON -

   {
        "id": "cLsrKP9FQU-3yUaE6gaYwgT2qe43q4pAqMb4Kr9Cdp4",
        "creationTimestamp": "2019-04-08T06:17:53.349594Z",
        "appRoleId": "00000000-0000-0000-0000-000000000000",
        "principalDisplayName": "<User Name>",
        "principalId": "282bbb70-45ff-4f41-b7c9-4684ea0698c2",
        "principalType": "User",
        "resourceDisplayName": "Postman",
        "resourceId": "d24064b4-1ee0-4507-a220-6faab7ba3fe0"
    },

С

    {
        "id": "b5bb2bb9-bb5e-426a-a107-d2212020f614",
        "deletedDateTime": null,
        "isFallbackPublicClient": false,
        "appId": "c21feb4a-040e-4067-8c14-55b1e015fc17",
        "applicationTemplateId": null,
        "identifierUris": [
            "https://<OrgName>.onmicrosoft.com/5d959b28-00fd-4f67-8d14-1a6276919b28"
        ],
        "createdDateTime": "2019-02-27T07:33:40Z",
        "displayName": "Postman",
        "isDeviceOnlyAuthSupported": null,
        "groupMembershipClaims": null,
        "optionalClaims": null,
        "orgRestrictions": [],
        "publisherDomain": "<OrgName>.onmicrosoft.com",
        "signInAudience": "AzureADMyOrg",
        "tags": [],
        "tokenEncryptionKeyId": null,
        "api": {
            "requestedAccessTokenVersion": null,
            "acceptMappedClaims": null,
            "knownClientApplications": [],
            "oauth2PermissionScopes": [
                {
                    "adminConsentDescription": "Allow the application to access Postman on behalf of the signed-in user.",
                    "adminConsentDisplayName": "Access Postman",
                    "id": "2e9e3ada-8570-4e8a-b02b-f0822f4fd63c",
                    "isEnabled": true,
                    "type": "User",
                    "userConsentDescription": "Allow the application to access Postman on your behalf.",
                    "userConsentDisplayName": "Access Postman",
                    "value": "user_impersonation"
                }
            ],
            "preAuthorizedApplications": []
        },

Я хочу отфильтровать назначенные мне приложения из основного списка приложений. Какой идентификатор должен совпадать?

Edited-

Я получаю ошибку 403 при вызове этого API через веб-часть - https://graph.microsoft.com/beta/applications

private _getListApplications(param): Promise<any> {
return this.context.aadHttpClientFactory
  .getClient('https://graph.microsoft.com')
  .then((client: AadHttpClient) => {
    return client
      .get("https://graph.microsoft.com/beta/applications", AadHttpClient.configurations.v1);
  }).
  then((responseListAllApps: SPHttpClientResponse) => {
    return responseListAllApps.json();
  });

}

{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"request-id": "a0cae64d-ae22-47a3-a765-3abe2b1c34a1",
"date": "2019-04-08T09:23:25"
}
}
}

1 Ответ

0 голосов
/ 08 апреля 2019

Нет, ID не сопоставлен напрямую, вы не можете сделать это через эти два API.Вам необходимо использовать GET https://graph.microsoft.com/beta/servicePrincipals/xxxxxxxxx в качестве носителя.

Сначала вызовите GET https://graph.microsoft.com/beta/me/appRoleAssignments, скопируйте resourceId в ответе, это object id целевого ресурса (субъекта службы), для которогоназначение было сделано.Затем позвоните GET https://graph.microsoft.com/beta/servicePrincipals/<resourceId>, appId в ответе - application id приложения AD.Затем вызовите GET https://graph.microsoft.com/beta/applications, appId в ответе совпадает с appId, перенастроенным на GET https://graph.microsoft.com/beta/servicePrincipals/<resourceId>.Затем вы можете сопоставить их.

Подробнее о свойствах см. Эти три ссылки:

...