Skip to content

Bug report: aad app add does not get service principals that only have trailing slash #2188

@rajyraman

Description

@rajyraman

Description

When I use the aad app add command, I get the error the Service principal not found, even though the api name is correct. When I looked at the code it seems that the reason is this line

const servicePrincipal = this.items.find(sp => sp.servicePrincipalNames.indexOf(servicePrincipalName) > -1);

For example when I try to register a new application with API access to Dynamics, it gives this error.

image

But when I look at the detail for this service principal, this service principal name ends with a slash.

image

When I use "00000007-0000-0000-c000-000000000000/*.crm.dynamics.com" the application registers correctly.

Steps to reproduce

Try to register a new application with this command

m365 aad app add --name "My AAD app" --withSecret --apisDelegated "https://admin.services.crm.dynamics.com/user_impersonation" --redirectUris "https://global.consent.azure-apim.net/redirect" --platform web

Expected result

The application should be registered with Dynamics CRM permission
image

Actual result

Error: Service principal https://admin.services.crm.dynamics.com not found

Environment

Windows 10, Powershell 7, 3.5.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions