NamedLocation erstellen
Artikel
07/18/2022
6 Minuten Lesedauer
3 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Erstellt ein neues namedLocation-Objekt. Benannte Speicherorte können entweder ipNamedLocation- oder countryNamedLocation-Objekte sein.
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie im Artikel zum Thema Berechtigungen .
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
Policy.Read.All und Policy.ReadWrite.ConditionalAccess
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Anwendung
Policy.Read.All und Policy.ReadWrite.ConditionalAccess
HTTP-Anforderung
POST /identity/conditionalAccess/namedLocations
Name
Beschreibung
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json. Erforderlich.
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines ipNamedLocation- oder countryNamedLocation-Objekts an. Sie müssen die @odata.type des abgeleiteten Typs angeben, d. h. #microsoft.graph.ipNamedLocation für ein ipNamedLocation -Objekt oder #microsoft.graph.countryNamedLocation für ein countryNamedLocation -Objekt.
In der folgenden Tabelle sind die Eigenschaften aufgeführt, die zum Erstellen eines ipNamedLocation-Objekts erforderlich sind.
Eigenschaft
Typ
Beschreibung
displayName
Zeichenfolge
Lesbarer Name des Speicherorts. Erforderlich.
ipRanges
ipRange -Sammlung
Liste der IP-Adressbereiche im IPv4 CIDR-Format (z. B. 1.2.3.4/32) oder eines beliebigen zulässigen IPv6-Formats von IETF RFC596. Erforderlich. Die @odata.type des ipRange ist ebenfalls erforderlich.
In der folgenden Tabelle sind die Eigenschaften aufgeführt, die zum Erstellen eines countryNamedLocation-Objekts erforderlich sind.
Eigenschaft
Typ
Beschreibung
countriesAndRegions
String collection
Liste der Länder und/oder Regionen im durch ISO 3166-2 angegebenen Format mit zwei Buchstaben. Erforderlich.
displayName
Zeichenfolge
Lesbarer Name des Speicherorts. Erforderlich.
Antwort
Bei erfolgreicher Ausführung gibt die Methode den 201 Created Antwortcode und ein neues objekt "ipNamedLocation" oder "countryNamedLocation" im Antworttext zurück.
Beispiele
Beispiel 1: Erstellen einer ipNamedLocation
Anforderung
Nachfolgend sehen Sie ein Beispiel der Anforderung.
POST https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations
Content-type: application/json
{
"@odata.type": "#microsoft.graph.ipNamedLocation",
"displayName": "Untrusted IP named location",
"isTrusted": false,
"ipRanges": [
{
"@odata.type": "#microsoft.graph.iPv4CidrRange",
"cidrAddress": "12.34.221.11/22"
},
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:0:9d38:90d6:0:0:0:0/63"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var namedLocation = new IpNamedLocation
{
DisplayName = "Untrusted IP named location",
IsTrusted = false,
IpRanges = new List<IpRange>()
{
new IPv4CidrRange
{
CidrAddress = "12.34.221.11/22"
},
new IPv6CidrRange
{
CidrAddress = "2001:0:9d38:90d6:0:0:0:0/63"
}
}
};
await graphClient.Identity.ConditionalAccess.NamedLocations
.Request()
.AddAsync(namedLocation);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const namedLocation = {
'@odata.type': '#microsoft.graph.ipNamedLocation',
displayName: 'Untrusted IP named location',
isTrusted: false,
ipRanges: [
{
'@odata.type': '#microsoft.graph.iPv4CidrRange',
cidrAddress: '12.34.221.11/22'
},
{
'@odata.type': '#microsoft.graph.iPv6CidrRange',
cidrAddress: '2001:0:9d38:90d6:0:0:0:0/63'
}
]
};
await client.api('/identity/conditionalAccess/namedLocations')
.post(namedLocation);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/conditionalAccess/namedLocations"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphNamedLocation *namedLocation = [[MSGraphNamedLocation alloc] init];
[namedLocation setDisplayName:@"Untrusted IP named location"];
[namedLocation setIsTrusted: false];
NSMutableArray *ipRangesList = [[NSMutableArray alloc] init];
MSGraphIpRange *ipRanges = [[MSGraphIpRange alloc] init];
[ipRanges setCidrAddress:@"12.34.221.11/22"];
[ipRangesList addObject: ipRanges];
MSGraphIpRange *ipRanges = [[MSGraphIpRange alloc] init];
[ipRanges setCidrAddress:@"2001:0:9d38:90d6:0:0:0:0/63"];
[ipRangesList addObject: ipRanges];
[namedLocation setIpRanges:ipRangesList];
NSError *error;
NSData *namedLocationData = [namedLocation getSerializedDataWithError:&error];
[urlRequest setHTTPBody:namedLocationData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
IpNamedLocation namedLocation = new IpNamedLocation();
namedLocation.displayName = "Untrusted IP named location";
namedLocation.isTrusted = false;
LinkedList<IpRange> ipRangesList = new LinkedList<IpRange>();
IPv4CidrRange ipRanges = new IPv4CidrRange();
ipRanges.cidrAddress = "12.34.221.11/22";
ipRangesList.add(ipRanges);
IPv6CidrRange ipRanges1 = new IPv6CidrRange();
ipRanges1.cidrAddress = "2001:0:9d38:90d6:0:0:0:0/63";
ipRangesList.add(ipRanges1);
namedLocation.ipRanges = ipRangesList;
graphClient.identity().conditionalAccess().namedLocations()
.buildRequest()
.post(namedLocation);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewNamedLocation()
displayName := "Untrusted IP named location"
requestBody.SetDisplayName(&displayName)
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.ipNamedLocation",
"isTrusted": false,
"ipRanges": []Object {
}
}
result, err := graphClient.Identity().ConditionalAccess().NamedLocations().Post(requestBody)
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.ipNamedLocation"
DisplayName = "Untrusted IP named location"
IsTrusted = $false
IpRanges = @(
@{
"@odata.type" = "#microsoft.graph.iPv4CidrRange"
CidrAddress = "12.34.221.11/22"
}
@{
"@odata.type" = "#microsoft.graph.iPv6CidrRange"
CidrAddress = "2001:0:9d38:90d6:0:0:0:0/63"
}
)
}
New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#namedLocations/$entity",
"@odata.type": "#microsoft.graph.ipNamedLocation",
"id": "0854951d-5fc0-4eb1-b392-9b2c9d7949c2",
"displayName": "Untrusted IP named location",
"modifiedDateTime": "2019-09-04T01:11:34.9387578Z",
"createdDateTime": "2019-09-04T01:11:34.9387578Z",
"isTrusted": false,
"ipRanges": [
{
"@odata.type": "#microsoft.graph.iPv4CidrRange",
"cidrAddress": "12.34.221.11/22"
},
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:0:9d38:90d6:0:0:0:0/63"
}
]
}
Beispiel 2: Erstellen eines countryNamedLocation-Steuerelements
Anforderung
Nachfolgend sehen Sie ein Beispiel der Anforderung.
POST https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations
Content-type: application/json
{
"@odata.type": "#microsoft.graph.countryNamedLocation",
"displayName": "Named location with unknown countries and regions",
"countriesAndRegions": [
"US",
"GB"
],
"includeUnknownCountriesAndRegions": true
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var namedLocation = new CountryNamedLocation
{
DisplayName = "Named location with unknown countries and regions",
CountriesAndRegions = new List<String>()
{
"US",
"GB"
},
IncludeUnknownCountriesAndRegions = true
};
await graphClient.Identity.ConditionalAccess.NamedLocations
.Request()
.AddAsync(namedLocation);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const namedLocation = {
'@odata.type': '#microsoft.graph.countryNamedLocation',
displayName: 'Named location with unknown countries and regions',
countriesAndRegions: [
'US',
'GB'
],
includeUnknownCountriesAndRegions: true
};
await client.api('/identity/conditionalAccess/namedLocations')
.post(namedLocation);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/conditionalAccess/namedLocations"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphNamedLocation *namedLocation = [[MSGraphNamedLocation alloc] init];
[namedLocation setDisplayName:@"Named location with unknown countries and regions"];
NSMutableArray *countriesAndRegionsList = [[NSMutableArray alloc] init];
[countriesAndRegionsList addObject: @"US"];
[countriesAndRegionsList addObject: @"GB"];
[namedLocation setCountriesAndRegions:countriesAndRegionsList];
[namedLocation setIncludeUnknownCountriesAndRegions: true];
NSError *error;
NSData *namedLocationData = [namedLocation getSerializedDataWithError:&error];
[urlRequest setHTTPBody:namedLocationData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
CountryNamedLocation namedLocation = new CountryNamedLocation();
namedLocation.displayName = "Named location with unknown countries and regions";
LinkedList<String> countriesAndRegionsList = new LinkedList<String>();
countriesAndRegionsList.add("US");
countriesAndRegionsList.add("GB");
namedLocation.countriesAndRegions = countriesAndRegionsList;
namedLocation.includeUnknownCountriesAndRegions = true;
graphClient.identity().conditionalAccess().namedLocations()
.buildRequest()
.post(namedLocation);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewNamedLocation()
displayName := "Named location with unknown countries and regions"
requestBody.SetDisplayName(&displayName)
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.countryNamedLocation",
"countriesAndRegions": []String {
"US",
"GB",
}
"includeUnknownCountriesAndRegions": true,
}
result, err := graphClient.Identity().ConditionalAccess().NamedLocations().Post(requestBody)
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.countryNamedLocation"
DisplayName = "Named location with unknown countries and regions"
CountriesAndRegions = @(
"US"
"GB"
)
IncludeUnknownCountriesAndRegions = $true
}
New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#namedLocations/$entity",
"@odata.type": "#microsoft.graph.countryNamedLocation",
"id": "1c4427fd-0885-4a3d-8b23-09a899ffa959",
"displayName": "Named location with unknown countries and regions",
"modifiedDateTime": "2019-09-04T01:08:02.5249255Z",
"createdDateTime": "2019-09-04T01:08:02.5249255Z",
"countriesAndRegions": [
"US",
"GB"
],
"includeUnknownCountriesAndRegions": true
}