Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

microsoft graph api - how to set the service principle display name in azure active directory

I am trying to create a service principle in using Microsoft graph API. Following the document i refereed create service principle. I just want to identify the service principle that created through graph API. So i just add display name in graph API body.Below is my service principle Json body.

$RESOURCE_GROUP = "TESTRG"
POST https://graph.microsoft.com/v1.0/servicePrincipals
Content-type: application/json

{
  "appId": "65415bb1-9267-4313-bbf5-ae259732ee12",
     "displayName": "' + $RESOURCE_GROUP + "-" + $appId + '",

}

it returns an error message

{   "error": {     "code": "Request_BadRequest",     "message": "Property displayName on the service principal does not match the application
     | object.",     "innerError": {       "date": "2021-01-24T07:33:25",       "request-id": "80792870-6524-4373-434342-434343",      
     | "client-request-id": "80792870-6524-4373-434342-434343"     }   } }
question from:https://stackoverflow.com/questions/65868183/how-to-set-the-service-principle-display-name-in-azure-active-directory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here you need to make sure first you update the App displayName which you give for service principal and later update the service principal with the same displayName. Basically the servicePrinipal object validates its properties with the respective Application object. I have tested it in POSTMAN and found that it requires to update the display name on App object and later on Service Principal. Please check the below screenshots.

Update App object with new name PostmanGraphs:

enter image description here

Update Service Principal object with new name PostmanGraphs:

enter image description here

When an app object gets registered in AAD it creates a service principal automatically. See this document.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...