Namespace: microsoft.graph
Wichtig
Die APIs unter der /beta Version in Microsoft Graph können sich ändern. Die Verwendung dieser APIs in Produktionsanwendungen wird nicht unterstützt. Um festzustellen, ob eine API in v1.0 verfügbar ist, verwenden Sie die Version Selektor.
Entfernen sie einen Besitzer aus einem servicePrincipal-Objekt . Als empfohlene bewährte Methode sollten Dienstprinzipale mindestens zwei Besitzer haben.
Diese API ist in den folgenden nationalen Cloudbereitstellungen verfügbar.
| Weltweiter Service |
US Government L4 |
US Government L5 (DOD) |
China, betrieben von 21Vianet |
| ✅ |
✅ |
✅ |
✅ |
Berechtigungen
Wählen Sie die Berechtigungen aus, die für diese API als am wenigsten privilegiert markiert sind. Verwenden Sie eine höhere Berechtigung oder Berechtigungen nur, wenn Ihre App dies erfordert. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
| Berechtigungstyp |
Berechtigungen mit den geringsten Berechtigungen |
Berechtigungen mit höheren Berechtigungen |
| Delegiert (Geschäfts-, Schul- oder Unikonto) |
Application.ReadWrite.All |
Directory.ReadWrite.All |
| Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
| Application |
Application.ReadWrite.OwnedBy |
Application.ReadWrite.All, Directory.ReadWrite.All |
Wichtig
In delegierten Szenarien mit Geschäfts-, Schul- oder Unikonten muss dem angemeldeten Benutzer eine unterstützte Microsoft Entra Rolle oder eine benutzerdefinierte Rolle mit einer unterstützten Rollenberechtigung zugewiesen werden. Die folgenden Rollen mit den geringsten Berechtigungen werden für diesen Vorgang unterstützt.
- Hybrididentitätsadministrator
- Cloudanwendungsadministrator
- Anwendungsadministrator
HTTP-Anforderung
DELETE /servicePrincipals/{id}/owners/{id}/$ref
Anforderungstext
Geben Sie im Anforderungstext den Bezeichner des Verzeichnisobjekts an, das als Besitzer zugewiesen werden soll.
Antwort
Wenn die Methode erfolgreich verläuft, wird der Antwortcode 204 No Content zurückgegeben.
Beispiel
Anforderung
Das folgende Beispiel zeigt die Antwort.
DELETE https://graph.microsoft.com/v1.0/servicePrincipals/{id}/owners/{id}/$ref
Content-type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.ServicePrincipals.Item.Owners.Item.Ref;
var requestBody = new $refDeleteRequestBody
{
AdditionalData = new Dictionary<string, object>
{
{
"@odata.id" , "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.ServicePrincipals["{servicePrincipal-id}"].Owners["{directoryObject-id}"].Ref.DeleteAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphserviceprincipals "github.com/microsoftgraph/msgraph-sdk-go/serviceprincipals"
//other-imports
)
requestBody := graphserviceprincipals.New$refDeleteRequestBody()
additionalData := map[string]interface{}{
"@odata.id" : "https://graph.microsoft.com/v1.0/directoryObjects/{id}",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.ServicePrincipals().ByServicePrincipalId("servicePrincipal-id").Owners().ByDirectoryObjectId("directoryObject-id").Ref().Delete(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.serviceprincipals.item.owners.item.ref.$refDeleteRequestBody refDeleteRequestBody = new com.microsoft.graph.serviceprincipals.item.owners.item.ref.$refDeleteRequestBody();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("@odata.id", "https://graph.microsoft.com/v1.0/directoryObjects/{id}");
refDeleteRequestBody.setAdditionalData(additionalData);
graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").owners().byDirectoryObjectId("{directoryObject-id}").ref().delete(refDeleteRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/servicePrincipals/{id}/owners/{id}/$ref')
.delete();
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\ServicePrincipals\Item\Owners\Item\Ref\$refDeleteRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new $refDeleteRequestBody();
$additionalData = [
'@odata.id' => 'https://graph.microsoft.com/v1.0/directoryObjects/{id}',
];
$requestBody->setAdditionalData($additionalData);
$graphServiceClient->servicePrincipals()->byServicePrincipalId('servicePrincipal-id')->owners()->byDirectoryObjectId('directoryObject-id')->ref()->delete($requestBody)->wait();
Import-Module Microsoft.Graph.Applications
$params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}
Remove-MgServicePrincipalOwnerDirectoryObjectByRef -ServicePrincipalId $servicePrincipalId -DirectoryObjectId $directoryObjectId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.serviceprincipals.item.owners.item.ref.$ref_delete_request_body import $refDeleteRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = $refDeleteRequestBody(
additional_data = {
"@odata_id" : "https://graph.microsoft.com/v1.0/directoryObjects/{id}",
}
)
await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').owners.by_directory_object_id('directoryObject-id').ref.delete(request_body)
Antwort
Das folgende Beispiel zeigt die Antwort.
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 204 No Content