Namespace: microsoft.graph
Get a list of namedLocation objects.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Policy.Read.All |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Policy.Read.All |
Not available. |
Important
In delegated scenarios with work or school accounts where the signed-in user is acting on another user, they must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation.
- Global Secure Access Administrator - read standard properties
- Security Reader - read standard properties
- Security Administrator - read standard properties
- Global Reader
- Conditional Access Administrator
HTTP request
GET /identity/conditionalAccess/namedLocations
Optional query parameters
This method supports the $count
, $filter
, $orderby
, $select
, $skip
, and $top
OData query parameters to help customize the response. For general information, see OData query parameters.
Request body
Don't supply a request body for this method.
Response
If successful, this method returns a 200 OK
response code and a collection of namedLocation objects in the response body.
Examples
Example 1: List all namedLocations
Request
The following example shows a request.
GET https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ConditionalAccess.NamedLocations.GetAsync();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
namedLocations, err := graphClient.Identity().ConditionalAccess().NamedLocations().Get(context.Background(), nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
NamedLocationCollectionResponse result = graphClient.identity().conditionalAccess().namedLocations().get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let namedLocations = await client.api('/identity/conditionalAccess/namedLocations')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->identity()->conditionalAccess()->namedLocations()->get()->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.identity.conditional_access.named_locations.get()
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#conditionalAccess/namedLocations",
"value": [
{
"@odata.type": "#microsoft.graph.ipNamedLocation",
"id": "06e4ff15-ca6b-4843-9c34-3fdd1ce8f739",
"displayName": "IPv4 named location",
"modifiedDateTime": "2019-07-26T18:00:43.5796446Z",
"createdDateTime": "2018-06-22T11:56:12Z",
"isTrusted": false,
"ipRanges": [
{
"@odata.type": "#microsoft.graph.iPv4CidrRange",
"cidrAddress": "6.5.4.3/32"
},
{
"@odata.type": "#microsoft.graph.iPv4CidrRange",
"cidrAddress": "127.126.125.0/24"
}
]
},
{
"@odata.type": "#microsoft.graph.countryNamedLocation",
"id": "1b7f0916-7677-40d8-97a1-d606f4ed8fcf",
"displayName": "Country named location",
"modifiedDateTime": "2018-09-10T16:54:53.7238848Z",
"createdDateTime": "2018-09-10T16:54:53.7238848Z",
"countriesAndRegions": [
"US",
"CA"
],
"includeUnknownCountriesAndRegions": false
},
{
"@odata.type": "#microsoft.graph.ipNamedLocation",
"id": "05239353-9117-4d29-a6a1-89724cb61b8c",
"displayName": "Trusted IPv6 named location",
"modifiedDateTime": "2019-09-16T00:47:36.4967092Z",
"createdDateTime": "2019-09-15T21:53:34.5001162Z",
"isTrusted": true,
"ipRanges": [
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:4898:80e8:7:d92a:7695:fda1:9d62/48"
},
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:4898:80d8:7:d92a:7695:fda1:9d62/48"
}
]
}
]
}
Example 2: List all ipNamedLocations
Request
The following example shows a request.
GET https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations?$filter=isof('microsoft.graph.ipNamedLocation')
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ConditionalAccess.NamedLocations.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "isof('microsoft.graph.ipNamedLocation')";
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
graphidentity "github.com/microsoftgraph/msgraph-sdk-go/identity"
//other-imports
)
requestFilter := "isof('microsoft.graph.ipNamedLocation')"
requestParameters := &graphidentity.ConditionalAccessNamedLocationsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
}
configuration := &graphidentity.ConditionalAccessNamedLocationsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
namedLocations, err := graphClient.Identity().ConditionalAccess().NamedLocations().Get(context.Background(), configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
NamedLocationCollectionResponse result = graphClient.identity().conditionalAccess().namedLocations().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "isof('microsoft.graph.ipNamedLocation')";
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let namedLocations = await client.api('/identity/conditionalAccess/namedLocations')
.filter('isof(\'microsoft.graph.ipNamedLocation\')')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Identity\ConditionalAccess\NamedLocations\NamedLocationsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new NamedLocationsRequestBuilderGetRequestConfiguration();
$queryParameters = NamedLocationsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "isof('microsoft.graph.ipNamedLocation')";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->identity()->conditionalAccess()->namedLocations()->get($requestConfiguration)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Identity.SignIns
Get-MgIdentityConditionalAccessNamedLocation -Filter "isof('microsoft.graph.ipNamedLocation')"
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.identity.conditional_access.named_locations.named_locations_request_builder import NamedLocationsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = NamedLocationsRequestBuilder.NamedLocationsRequestBuilderGetQueryParameters(
filter = "isof('microsoft.graph.ipNamedLocation')",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.identity.conditional_access.named_locations.get(request_configuration = request_configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#conditionalAccess/namedLocations",
"value": [
{
"@odata.type": "#microsoft.graph.ipNamedLocation",
"id": "06e4ff15-ca6b-4843-9c34-3fdd1ce8f739",
"displayName": "IPv4 named location",
"modifiedDateTime": "2019-07-26T18:00:43.5796446Z",
"createdDateTime": "2018-06-22T11:56:12Z",
"isTrusted": false,
"ipRanges": [
{
"@odata.type": "#microsoft.graph.iPv4CidrRange",
"cidrAddress": "6.5.4.3/32"
},
{
"@odata.type": "#microsoft.graph.iPv4CidrRange",
"cidrAddress": "127.126.125.0/24"
}
]
},
{
"@odata.type": "#microsoft.graph.ipNamedLocation",
"id": "05239353-9117-4d29-a6a1-89724cb61b8c",
"displayName": "Trusted IPv6 named location",
"modifiedDateTime": "2019-09-16T00:47:36.4967092Z",
"createdDateTime": "2019-09-15T21:53:34.5001162Z",
"isTrusted": true,
"ipRanges": [
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:4898:80e8:7:d92a:7695:fda1:9d62/48"
},
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:4898:80d8:7:d92a:7695:fda1:9d62/48"
}
]
}
]
}
Example 3: List all namedLocations created after a certain date
Request
The following example shows a request.
GET https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations?$filter=createdDateTime ge 2019-09-01T00:00:00Z
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ConditionalAccess.NamedLocations.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "createdDateTime ge 2019-09-01T00:00:00Z";
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
graphidentity "github.com/microsoftgraph/msgraph-sdk-go/identity"
//other-imports
)
requestFilter := "createdDateTime ge 2019-09-01T00:00:00Z"
requestParameters := &graphidentity.ConditionalAccessNamedLocationsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
}
configuration := &graphidentity.ConditionalAccessNamedLocationsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
namedLocations, err := graphClient.Identity().ConditionalAccess().NamedLocations().Get(context.Background(), configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
NamedLocationCollectionResponse result = graphClient.identity().conditionalAccess().namedLocations().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "createdDateTime ge 2019-09-01T00:00:00Z";
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let namedLocations = await client.api('/identity/conditionalAccess/namedLocations')
.filter('createdDateTime ge 2019-09-01T00:00:00Z')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Identity\ConditionalAccess\NamedLocations\NamedLocationsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new NamedLocationsRequestBuilderGetRequestConfiguration();
$queryParameters = NamedLocationsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "createdDateTime ge 2019-09-01T00:00:00Z";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->identity()->conditionalAccess()->namedLocations()->get($requestConfiguration)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Identity.SignIns
Get-MgIdentityConditionalAccessNamedLocation -Filter "createdDateTime ge 2019-09-01T00:00:00Z"
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.identity.conditional_access.named_locations.named_locations_request_builder import NamedLocationsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = NamedLocationsRequestBuilder.NamedLocationsRequestBuilderGetQueryParameters(
filter = "createdDateTime ge 2019-09-01T00:00:00Z",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.identity.conditional_access.named_locations.get(request_configuration = request_configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#conditionalAccess/namedLocations",
"value": [
{
"@odata.type": "#microsoft.graph.ipNamedLocation",
"id": "05239353-9117-4d29-a6a1-89724cb61b8c",
"displayName": "Trusted IPv6 named location",
"modifiedDateTime": "2019-09-16T00:47:36.4967092Z",
"createdDateTime": "2019-09-15T21:53:34.5001162Z",
"isTrusted": true,
"ipRanges": [
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:4898:80e8:7:d92a:7695:fda1:9d62/48"
},
{
"@odata.type": "#microsoft.graph.iPv6CidrRange",
"cidrAddress": "2001:4898:80d8:7:d92a:7695:fda1:9d62/48"
}
]
}
]
}
Example 4: List all countryNamedLocations containing a certain country or region
Request
The following example shows a request.
GET https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations?$filter=microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ConditionalAccess.NamedLocations.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')";
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc identity conditional-access named-locations list --filter "microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')"
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
graphidentity "github.com/microsoftgraph/msgraph-sdk-go/identity"
//other-imports
)
requestFilter := "microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')"
requestParameters := &graphidentity.ConditionalAccessNamedLocationsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
}
configuration := &graphidentity.ConditionalAccessNamedLocationsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
namedLocations, err := graphClient.Identity().ConditionalAccess().NamedLocations().Get(context.Background(), configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
NamedLocationCollectionResponse result = graphClient.identity().conditionalAccess().namedLocations().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')";
});
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
let namedLocations = await client.api('/identity/conditionalAccess/namedLocations')
.filter('microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq \'CA\')')
.get();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Identity\ConditionalAccess\NamedLocations\NamedLocationsRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new NamedLocationsRequestBuilderGetRequestConfiguration();
$queryParameters = NamedLocationsRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->identity()->conditionalAccess()->namedLocations()->get($requestConfiguration)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Identity.SignIns
Get-MgIdentityConditionalAccessNamedLocation -Filter "microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')"
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.identity.conditional_access.named_locations.named_locations_request_builder import NamedLocationsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = NamedLocationsRequestBuilder.NamedLocationsRequestBuilderGetQueryParameters(
filter = "microsoft.graph.countryNamedLocation/countriesAndRegions/any(c: c eq 'CA')",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.identity.conditional_access.named_locations.get(request_configuration = request_configuration)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#conditionalAccess/namedLocations",
"value": [
{
"@odata.type": "#microsoft.graph.countryNamedLocation",
"id": "1b7f0916-7677-40d8-97a1-d606f4ed8fcf",
"displayName": "Country named location",
"modifiedDateTime": "2018-09-10T16:54:53.7238848Z",
"createdDateTime": "2018-09-10T16:54:53.7238848Z",
"countriesAndRegions": [
"US",
"CA"
],
"includeUnknownCountriesAndRegions": false
}
]
}