Namespace: microsoft.graph
Erstellen Sie ein neues delegatedAdminRelationship-Objekt .
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) |
DelegatedAdminRelationship.ReadWrite.All |
Nicht verfügbar. |
Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
Anwendung |
DelegatedAdminRelationship.ReadWrite.All |
Nicht verfügbar. |
Wichtig
Um diese API mithilfe von Anwendungsberechtigungen aufzurufen, müssen Sie den Dienstprinzipal bereitstellen, der durch appId2832473f-ec63-45fb-976f-5d45a7d4bb91
und delegierte Partnerkundenverwaltung im Partnermandanten identifiziert wird. Um den Dienstprinzipal im Partnermandanten bereitzustellen, rufen Sie die Create servicePrincipal-API auf.
HTTP-Anforderung
POST /tenantRelationships/delegatedAdminRelationships
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung des delegatedAdminRelationship-Objekts an .
Sie können die folgenden Eigenschaften angeben, wenn Sie eine delegatedAdminRelationship erstellen.
Eigenschaft |
Typ |
Beschreibung |
accessDetails |
microsoft.graph.delegatedAdminAccessDetails |
Die Bezeichner der Administratorrollen, auf die der Partner im Kundenmandanten Zugriff anfordert oder hat. Erforderlich. |
autoExtendDuration |
Dauer |
Die Dauer, um die die Gültigkeit der Beziehung automatisch verlängert wird, angegeben im ISO 8601-Format. Unterstützte Werte sind: P0D , PT0S , P180D . Der Standardwert ist PT0S .
PT0S gibt an, dass die Beziehung abläuft, wenn endDateTime erreicht ist und nicht automatisch verlängert wird. Optional. |
Kunde |
microsoft.graph.delegatedAdminRelationshipCustomerParticipant |
Der Anzeigename und der eindeutige Bezeichner des Kunden der Beziehung. Optional. |
displayName |
String |
Der Anzeigename der Beziehung, die zur einfachen Identifizierung verwendet wird. Muss für alle delegierten Administratorbeziehungen des Partners eindeutig sein. Erforderlich. Die maximale Länge beträgt 50 Zeichen. |
Dauer |
Dauer |
Die Dauer der Beziehung im ISO 8601-Format. Muss ein Wert zwischen P1D und P2Y inklusiv sein. Erforderlich. |
Antwort
Bei erfolgreicher Ausführung gibt die Methode den 201 Created
Antwortcode und ein delegatedAdminRelationship-Objekt im Antworttext zurück.
Die Antwort enthält einen Location-Header , der eine URL zur erstellten delegierten Administratorbeziehung enthält. Jedes delegatedAdminRelationship-Objekt enthält eine @odata.etag-Eigenschaft gemäß RFC2616.
Beispiele
Anforderung
POST https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships
Content-Type: application/json
{
"displayName": "Contoso admin relationship",
"duration": "P730D",
"customer": {
"tenantId": "4b827261-d21f-4aa9-b7db-7fa1f56fb163",
"displayName": "Contoso subsidiary Inc"
},
"accessDetails": {
"unifiedRoles": [
{
"roleDefinitionId": "29232cdf-9323-42fd-ade2-1d097af3e4de"
},
{
"roleDefinitionId": "3a2c62db-5318-420d-8d74-23affee5d9d5"
}
]
},
"autoExtendDuration": "P180D"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DelegatedAdminRelationship
{
DisplayName = "Contoso admin relationship",
Duration = TimeSpan.Parse("P730D"),
Customer = new DelegatedAdminRelationshipCustomerParticipant
{
TenantId = "4b827261-d21f-4aa9-b7db-7fa1f56fb163",
DisplayName = "Contoso subsidiary Inc",
},
AccessDetails = new DelegatedAdminAccessDetails
{
UnifiedRoles = new List<UnifiedRole>
{
new UnifiedRole
{
RoleDefinitionId = "29232cdf-9323-42fd-ade2-1d097af3e4de",
},
new UnifiedRole
{
RoleDefinitionId = "3a2c62db-5318-420d-8d74-23affee5d9d5",
},
},
},
AutoExtendDuration = TimeSpan.Parse("P180D"),
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.TenantRelationships.DelegatedAdminRelationships.PostAsync(requestBody);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
mgc tenant-relationships delegated-admin-relationships create --body '{\
"displayName": "Contoso admin relationship",\
"duration": "P730D",\
"customer": {\
"tenantId": "4b827261-d21f-4aa9-b7db-7fa1f56fb163",\
"displayName": "Contoso subsidiary Inc"\
},\
"accessDetails": {\
"unifiedRoles": [\
{\
"roleDefinitionId": "29232cdf-9323-42fd-ade2-1d097af3e4de"\
},\
{\
"roleDefinitionId": "3a2c62db-5318-420d-8d74-23affee5d9d5"\
}\
]\
},\
"autoExtendDuration": "P180D"\
}\
'
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDelegatedAdminRelationship()
displayName := "Contoso admin relationship"
requestBody.SetDisplayName(&displayName)
duration , err := abstractions.ParseISODuration("P730D")
requestBody.SetDuration(&duration)
customer := graphmodels.NewDelegatedAdminRelationshipCustomerParticipant()
tenantId := "4b827261-d21f-4aa9-b7db-7fa1f56fb163"
customer.SetTenantId(&tenantId)
displayName := "Contoso subsidiary Inc"
customer.SetDisplayName(&displayName)
requestBody.SetCustomer(customer)
accessDetails := graphmodels.NewDelegatedAdminAccessDetails()
unifiedRole := graphmodels.NewUnifiedRole()
roleDefinitionId := "29232cdf-9323-42fd-ade2-1d097af3e4de"
unifiedRole.SetRoleDefinitionId(&roleDefinitionId)
unifiedRole1 := graphmodels.NewUnifiedRole()
roleDefinitionId := "3a2c62db-5318-420d-8d74-23affee5d9d5"
unifiedRole1.SetRoleDefinitionId(&roleDefinitionId)
unifiedRoles := []graphmodels.UnifiedRoleable {
unifiedRole,
unifiedRole1,
}
accessDetails.SetUnifiedRoles(unifiedRoles)
requestBody.SetAccessDetails(accessDetails)
autoExtendDuration , err := abstractions.ParseISODuration("P180D")
requestBody.SetAutoExtendDuration(&autoExtendDuration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
delegatedAdminRelationships, err := graphClient.TenantRelationships().DelegatedAdminRelationships().Post(context.Background(), requestBody, nil)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DelegatedAdminRelationship delegatedAdminRelationship = new DelegatedAdminRelationship();
delegatedAdminRelationship.setDisplayName("Contoso admin relationship");
PeriodAndDuration duration = PeriodAndDuration.ofDuration(Duration.parse("P730D"));
delegatedAdminRelationship.setDuration(duration);
DelegatedAdminRelationshipCustomerParticipant customer = new DelegatedAdminRelationshipCustomerParticipant();
customer.setTenantId("4b827261-d21f-4aa9-b7db-7fa1f56fb163");
customer.setDisplayName("Contoso subsidiary Inc");
delegatedAdminRelationship.setCustomer(customer);
DelegatedAdminAccessDetails accessDetails = new DelegatedAdminAccessDetails();
LinkedList<UnifiedRole> unifiedRoles = new LinkedList<UnifiedRole>();
UnifiedRole unifiedRole = new UnifiedRole();
unifiedRole.setRoleDefinitionId("29232cdf-9323-42fd-ade2-1d097af3e4de");
unifiedRoles.add(unifiedRole);
UnifiedRole unifiedRole1 = new UnifiedRole();
unifiedRole1.setRoleDefinitionId("3a2c62db-5318-420d-8d74-23affee5d9d5");
unifiedRoles.add(unifiedRole1);
accessDetails.setUnifiedRoles(unifiedRoles);
delegatedAdminRelationship.setAccessDetails(accessDetails);
PeriodAndDuration autoExtendDuration = PeriodAndDuration.ofDuration(Duration.parse("P180D"));
delegatedAdminRelationship.setAutoExtendDuration(autoExtendDuration);
DelegatedAdminRelationship result = graphClient.tenantRelationships().delegatedAdminRelationships().post(delegatedAdminRelationship);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
const options = {
authProvider,
};
const client = Client.init(options);
const delegatedAdminRelationship = {
displayName: 'Contoso admin relationship',
duration: 'P730D',
customer: {
tenantId: '4b827261-d21f-4aa9-b7db-7fa1f56fb163',
displayName: 'Contoso subsidiary Inc'
},
accessDetails: {
unifiedRoles: [
{
roleDefinitionId: '29232cdf-9323-42fd-ade2-1d097af3e4de'
},
{
roleDefinitionId: '3a2c62db-5318-420d-8d74-23affee5d9d5'
}
]
},
autoExtendDuration: 'P180D'
};
await client.api('/tenantRelationships/delegatedAdminRelationships')
.post(delegatedAdminRelationship);
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\DelegatedAdminRelationship;
use Microsoft\Graph\Generated\Models\DelegatedAdminRelationshipCustomerParticipant;
use Microsoft\Graph\Generated\Models\DelegatedAdminAccessDetails;
use Microsoft\Graph\Generated\Models\UnifiedRole;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DelegatedAdminRelationship();
$requestBody->setDisplayName('Contoso admin relationship');
$requestBody->setDuration(new \DateInterval('P730D'));
$customer = new DelegatedAdminRelationshipCustomerParticipant();
$customer->setTenantId('4b827261-d21f-4aa9-b7db-7fa1f56fb163');
$customer->setDisplayName('Contoso subsidiary Inc');
$requestBody->setCustomer($customer);
$accessDetails = new DelegatedAdminAccessDetails();
$unifiedRolesUnifiedRole1 = new UnifiedRole();
$unifiedRolesUnifiedRole1->setRoleDefinitionId('29232cdf-9323-42fd-ade2-1d097af3e4de');
$unifiedRolesArray []= $unifiedRolesUnifiedRole1;
$unifiedRolesUnifiedRole2 = new UnifiedRole();
$unifiedRolesUnifiedRole2->setRoleDefinitionId('3a2c62db-5318-420d-8d74-23affee5d9d5');
$unifiedRolesArray []= $unifiedRolesUnifiedRole2;
$accessDetails->setUnifiedRoles($unifiedRolesArray);
$requestBody->setAccessDetails($accessDetails);
$requestBody->setAutoExtendDuration(new \DateInterval('P180D'));
$result = $graphServiceClient->tenantRelationships()->delegatedAdminRelationships()->post($requestBody)->wait();
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
Import-Module Microsoft.Graph.Identity.Partner
$params = @{
displayName = "Contoso admin relationship"
duration = "P730D"
customer = @{
tenantId = "4b827261-d21f-4aa9-b7db-7fa1f56fb163"
displayName = "Contoso subsidiary Inc"
}
accessDetails = @{
unifiedRoles = @(
@{
roleDefinitionId = "29232cdf-9323-42fd-ade2-1d097af3e4de"
}
@{
roleDefinitionId = "3a2c62db-5318-420d-8d74-23affee5d9d5"
}
)
}
autoExtendDuration = "P180D"
}
New-MgTenantRelationshipDelegatedAdminRelationship -BodyParameter $params
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.delegated_admin_relationship import DelegatedAdminRelationship
from msgraph.generated.models.delegated_admin_relationship_customer_participant import DelegatedAdminRelationshipCustomerParticipant
from msgraph.generated.models.delegated_admin_access_details import DelegatedAdminAccessDetails
from msgraph.generated.models.unified_role import UnifiedRole
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DelegatedAdminRelationship(
display_name = "Contoso admin relationship",
duration = "P730D",
customer = DelegatedAdminRelationshipCustomerParticipant(
tenant_id = "4b827261-d21f-4aa9-b7db-7fa1f56fb163",
display_name = "Contoso subsidiary Inc",
),
access_details = DelegatedAdminAccessDetails(
unified_roles = [
UnifiedRole(
role_definition_id = "29232cdf-9323-42fd-ade2-1d097af3e4de",
),
UnifiedRole(
role_definition_id = "3a2c62db-5318-420d-8d74-23affee5d9d5",
),
],
),
auto_extend_duration = "P180D",
)
result = await graph_client.tenant_relationships.delegated_admin_relationships.post(request_body)
Einzelheiten darüber, wie Sie das SDK zu Ihrem Projekt hinzufügen und eine authProvider-Instanz erstellen, finden Sie in der SDK-Dokumentation.
Antwort
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 201 Created
Content-Type: application/json
Location: https://graph.microsoft.com/v1.0/tenantRelationships/delegatedAdminRelationships/5d027261-d21f-4aa9-b7db-7fa1f56fb163-8777b240-c6f0-4469-9e98-a3205431b836
{
"@odata.type": "#microsoft.graph.delegatedAdminRelationship",
"@odata.context": "https://graph.microsoft.com/v1.0/tenantRelationships/$metadata#delegatedAdminRelationships",
"@odata.etag": "W/\"JyIxODAwZTY4My0wMDAwLTAyMDAtMDAwMC02MTU0OWFmMDAwMDAiJw==\"",
"id": "5d027261-d21f-4aa9-b7db-7fa1f56fb163-8777b240-c6f0-4469-9e98-a3205431b836",
"displayName": "Contoso admin relationship",
"duration": "P730D",
"customer": {
"tenantId": "4b827261-d21f-4aa9-b7db-7fa1f56fb163",
"displayName": "Contoso subsidiary Inc"
},
"accessDetails": {
"unifiedRoles": [
{
"roleDefinitionId": "29232cdf-9323-42fd-ade2-1d097af3e4de"
},
{
"roleDefinitionId": "3a2c62db-5318-420d-8d74-23affee5d9d5"
}
]
},
"status": "created",
"autoExtendDuration": "P180D",
"createdDateTime": "2022-02-10T11:24:42.3148266Z",
"lastModifiedDateTime": "2022-02-10T11:24:42.3148266Z",
"activatedDateTime": "",
"endDateTime": "2024-02-10T11:24:42.3148266Z"
}