Namespace: microsoft.graph
Importante
As APIs na versão /beta
no Microsoft Graph estão sujeitas a alterações. Não há suporte para o uso dessas APIs em aplicativos de produção. Para determinar se uma API está disponível na v1.0, use o seletor Versão.
Crie um novo objeto customSecurityAttributeDefinition .
Esta API está disponível nas seguintes implementações de cloud nacionais.
Serviço global |
US Government L4 |
US Government L5 (DOD) |
China operada pela 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissões
Escolha a permissão ou permissões marcadas como menos privilegiadas para esta API. Utilize uma permissão ou permissões com privilégios mais elevados apenas se a sua aplicação o exigir. Para obter detalhes sobre as permissões delegadas e de aplicação, veja Tipos de permissão. Para saber mais sobre estas permissões, veja a referência de permissões.
Tipo de permissão |
Permissões com menos privilégios |
Permissões com privilégios superiores |
Delegado (conta corporativa ou de estudante) |
CustomSecAttributeDefinition.ReadWrite.All |
Indisponível. |
Delegado (conta pessoal da Microsoft) |
Sem suporte. |
Sem suporte. |
Application |
CustomSecAttributeDefinition.ReadWrite.All |
Indisponível. |
Importante
Em cenários delegados com contas escolares ou profissionais, o utilizador com sessão iniciada tem de ter uma função de Microsoft Entra suportada ou uma função personalizada com uma permissão de função suportada.
O Administrador de Definição de Atributos é a única função com privilégios suportada para esta operação.
Por predefinição, o Administrador Global e outras funções de administrador não têm permissões para ler, definir ou atribuir atributos de segurança personalizados.
Solicitação HTTP
POST /directory/customSecurityAttributeDefinitions
Nome |
Descrição |
Autorização |
{token} de portador. Obrigatório. Saiba mais sobre autenticação e autorização. |
Content-Type |
application/json. Obrigatório. |
Corpo da solicitação
No corpo do pedido, forneça uma representação JSON do objeto customSecurityAttributeDefinition .
A tabela seguinte mostra as propriedades que pode configurar quando cria uma customSecurityAttributeDefinition.
Propriedade |
Tipo |
Descrição |
attributeSet |
Cadeia de caracteres |
Nome do conjunto de atributos. Sensível às maiúsculas e minúsculas. Obrigatório. |
description |
Cadeia de caracteres |
Descrição do atributo de segurança personalizado. Pode ter até 128 carateres e incluir carateres Unicode. Não é possível conter espaços ou carateres especiais. Pode ser alterado mais tarde. Opcional. |
isCollection |
Booliano |
Indica se vários valores podem ser atribuídos ao atributo de segurança personalizado. Não pode ser alterado mais tarde. Se o tipo estiver definido como Boolean , isCollection não pode ser definido como true . Obrigatório. |
isSearchable |
Booliano |
Indica se os valores de atributos de segurança personalizados estão indexados para pesquisa em objetos que são valores de atributo atribuídos. Não pode ser alterado mais tarde. Obrigatório. |
nome |
Cadeia de caracteres |
Nome do atributo de segurança personalizado. Tem de ser exclusivo dentro de um conjunto de atributos. Pode ter até 32 carateres de comprimento e incluir carateres Unicode. Não é possível conter espaços ou carateres especiais. Não pode ser alterado mais tarde. Sensível às maiúsculas e minúsculas. Obrigatório. |
status |
Cadeia de caracteres |
Especifica se o atributo de segurança personalizado está ativo ou desativado. Os valores aceitáveis são Available e Deprecated . Pode ser alterado mais tarde. Obrigatório. |
type |
Cadeia de caracteres |
Tipo de dados para os valores de atributos de segurança personalizados. Os tipos suportados são: Boolean , Integer e String . Não pode ser alterado mais tarde. Obrigatório. |
usePreDefinedValuesOnly |
Booliano |
Indica se apenas os valores predefinidos podem ser atribuídos ao atributo de segurança personalizado. Se definido como false , os valores de forma livre são permitidos. Posteriormente, pode ser alterado de true para false , mas não pode ser alterado de false para true . Se o tipo estiver definido como Boolean , usePreDefinedValuesOnly não pode ser definido como true . Obrigatório. |
A propriedade ID é gerada automaticamente e não pode ser definida.
Resposta
Se for bem-sucedido, este método devolve um 201 Created
código de resposta e um objeto customSecurityAttributeDefinition no corpo da resposta.
Exemplos
Exemplo 1: adicionar um atributo de segurança personalizado
O exemplo seguinte adiciona uma nova definição de atributo de segurança personalizada que é um valor de forma livre único do tipo Cadeia.
- Conjunto de atributos:
Engineering
- Atributo:
ProjectDate
Solicitação
O exemplo a seguir mostra uma solicitação.
POST https://graph.microsoft.com/beta/directory/customSecurityAttributeDefinitions
Content-Type: application/json
{
"attributeSet":"Engineering",
"description":"Target completion date",
"isCollection":false,
"isSearchable":true,
"name":"ProjectDate",
"status":"Available",
"type":"String",
"usePreDefinedValuesOnly": false
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new CustomSecurityAttributeDefinition
{
AttributeSet = "Engineering",
Description = "Target completion date",
IsCollection = false,
IsSearchable = true,
Name = "ProjectDate",
Status = "Available",
Type = "String",
UsePreDefinedValuesOnly = false,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.CustomSecurityAttributeDefinitions.PostAsync(requestBody);
mgc-beta directory custom-security-attribute-definitions create --body '{\
"attributeSet":"Engineering",\
"description":"Target completion date",\
"isCollection":false,\
"isSearchable":true,\
"name":"ProjectDate",\
"status":"Available",\
"type":"String",\
"usePreDefinedValuesOnly": false\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomSecurityAttributeDefinition()
attributeSet := "Engineering"
requestBody.SetAttributeSet(&attributeSet)
description := "Target completion date"
requestBody.SetDescription(&description)
isCollection := false
requestBody.SetIsCollection(&isCollection)
isSearchable := true
requestBody.SetIsSearchable(&isSearchable)
name := "ProjectDate"
requestBody.SetName(&name)
status := "Available"
requestBody.SetStatus(&status)
type := "String"
requestBody.SetType(&type)
usePreDefinedValuesOnly := false
requestBody.SetUsePreDefinedValuesOnly(&usePreDefinedValuesOnly)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
customSecurityAttributeDefinitions, err := graphClient.Directory().CustomSecurityAttributeDefinitions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
CustomSecurityAttributeDefinition customSecurityAttributeDefinition = new CustomSecurityAttributeDefinition();
customSecurityAttributeDefinition.setAttributeSet("Engineering");
customSecurityAttributeDefinition.setDescription("Target completion date");
customSecurityAttributeDefinition.setIsCollection(false);
customSecurityAttributeDefinition.setIsSearchable(true);
customSecurityAttributeDefinition.setName("ProjectDate");
customSecurityAttributeDefinition.setStatus("Available");
customSecurityAttributeDefinition.setType("String");
customSecurityAttributeDefinition.setUsePreDefinedValuesOnly(false);
CustomSecurityAttributeDefinition result = graphClient.directory().customSecurityAttributeDefinitions().post(customSecurityAttributeDefinition);
const options = {
authProvider,
};
const client = Client.init(options);
const customSecurityAttributeDefinition = {
attributeSet: 'Engineering',
description: 'Target completion date',
isCollection: false,
isSearchable: true,
name: 'ProjectDate',
status: 'Available',
type: 'String',
usePreDefinedValuesOnly: false
};
await client.api('/directory/customSecurityAttributeDefinitions')
.version('beta')
.post(customSecurityAttributeDefinition);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\CustomSecurityAttributeDefinition;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CustomSecurityAttributeDefinition();
$requestBody->setAttributeSet('Engineering');
$requestBody->setDescription('Target completion date');
$requestBody->setIsCollection(false);
$requestBody->setIsSearchable(true);
$requestBody->setName('ProjectDate');
$requestBody->setStatus('Available');
$requestBody->setType('String');
$requestBody->setUsePreDefinedValuesOnly(false);
$result = $graphServiceClient->directory()->customSecurityAttributeDefinitions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
attributeSet = "Engineering"
description = "Target completion date"
isCollection = $false
isSearchable = $true
name = "ProjectDate"
status = "Available"
type = "String"
usePreDefinedValuesOnly = $false
}
New-MgBetaDirectoryCustomSecurityAttributeDefinition -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.custom_security_attribute_definition import CustomSecurityAttributeDefinition
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CustomSecurityAttributeDefinition(
attribute_set = "Engineering",
description = "Target completion date",
is_collection = False,
is_searchable = True,
name = "ProjectDate",
status = "Available",
type = "String",
use_pre_defined_values_only = False,
)
result = await graph_client.directory.custom_security_attribute_definitions.post(request_body)
Resposta
O exemplo a seguir mostra a resposta.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#directory/customSecurityAttributeDefinitions/$entity",
"attributeSet": "Engineering",
"description": "Target completion date",
"id": "Engineering_ProjectDate",
"isCollection": false,
"isSearchable": true,
"name": "ProjectDate",
"status": "Available",
"type": "String",
"usePreDefinedValuesOnly": false
}
Exemplo 2: adicionar um atributo de segurança personalizado que suporte vários valores predefinidos
O exemplo seguinte adiciona uma nova definição de atributo de segurança personalizada que suporta vários valores do tipo Cadeia predefinidos.
- Conjunto de atributos:
Engineering
- Atributo:
Project
Solicitação
O exemplo a seguir mostra uma solicitação.
POST https://graph.microsoft.com/beta/directory/customSecurityAttributeDefinitions
Content-Type: application/json
Content-length: 310
{
"attributeSet":"Engineering",
"description":"Active projects for user",
"isCollection":true,
"isSearchable":true,
"name":"Project",
"status":"Available",
"type":"String",
"usePreDefinedValuesOnly": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new CustomSecurityAttributeDefinition
{
AttributeSet = "Engineering",
Description = "Active projects for user",
IsCollection = true,
IsSearchable = true,
Name = "Project",
Status = "Available",
Type = "String",
UsePreDefinedValuesOnly = true,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.CustomSecurityAttributeDefinitions.PostAsync(requestBody);
mgc-beta directory custom-security-attribute-definitions create --body '{\
"attributeSet":"Engineering",\
"description":"Active projects for user",\
"isCollection":true,\
"isSearchable":true,\
"name":"Project",\
"status":"Available",\
"type":"String",\
"usePreDefinedValuesOnly": true\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomSecurityAttributeDefinition()
attributeSet := "Engineering"
requestBody.SetAttributeSet(&attributeSet)
description := "Active projects for user"
requestBody.SetDescription(&description)
isCollection := true
requestBody.SetIsCollection(&isCollection)
isSearchable := true
requestBody.SetIsSearchable(&isSearchable)
name := "Project"
requestBody.SetName(&name)
status := "Available"
requestBody.SetStatus(&status)
type := "String"
requestBody.SetType(&type)
usePreDefinedValuesOnly := true
requestBody.SetUsePreDefinedValuesOnly(&usePreDefinedValuesOnly)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
customSecurityAttributeDefinitions, err := graphClient.Directory().CustomSecurityAttributeDefinitions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
CustomSecurityAttributeDefinition customSecurityAttributeDefinition = new CustomSecurityAttributeDefinition();
customSecurityAttributeDefinition.setAttributeSet("Engineering");
customSecurityAttributeDefinition.setDescription("Active projects for user");
customSecurityAttributeDefinition.setIsCollection(true);
customSecurityAttributeDefinition.setIsSearchable(true);
customSecurityAttributeDefinition.setName("Project");
customSecurityAttributeDefinition.setStatus("Available");
customSecurityAttributeDefinition.setType("String");
customSecurityAttributeDefinition.setUsePreDefinedValuesOnly(true);
CustomSecurityAttributeDefinition result = graphClient.directory().customSecurityAttributeDefinitions().post(customSecurityAttributeDefinition);
const options = {
authProvider,
};
const client = Client.init(options);
const customSecurityAttributeDefinition = {
attributeSet: 'Engineering',
description: 'Active projects for user',
isCollection: true,
isSearchable: true,
name: 'Project',
status: 'Available',
type: 'String',
usePreDefinedValuesOnly: true
};
await client.api('/directory/customSecurityAttributeDefinitions')
.version('beta')
.post(customSecurityAttributeDefinition);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\CustomSecurityAttributeDefinition;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CustomSecurityAttributeDefinition();
$requestBody->setAttributeSet('Engineering');
$requestBody->setDescription('Active projects for user');
$requestBody->setIsCollection(true);
$requestBody->setIsSearchable(true);
$requestBody->setName('Project');
$requestBody->setStatus('Available');
$requestBody->setType('String');
$requestBody->setUsePreDefinedValuesOnly(true);
$result = $graphServiceClient->directory()->customSecurityAttributeDefinitions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
attributeSet = "Engineering"
description = "Active projects for user"
isCollection = $true
isSearchable = $true
name = "Project"
status = "Available"
type = "String"
usePreDefinedValuesOnly = $true
}
New-MgBetaDirectoryCustomSecurityAttributeDefinition -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.custom_security_attribute_definition import CustomSecurityAttributeDefinition
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CustomSecurityAttributeDefinition(
attribute_set = "Engineering",
description = "Active projects for user",
is_collection = True,
is_searchable = True,
name = "Project",
status = "Available",
type = "String",
use_pre_defined_values_only = True,
)
result = await graph_client.directory.custom_security_attribute_definitions.post(request_body)
Resposta
O exemplo a seguir mostra a resposta.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#directory/customSecurityAttributeDefinitions/$entity",
"attributeSet": "Engineering",
"description": "Active projects for user",
"id": "Engineering_Project",
"isCollection": true,
"isSearchable": true,
"name": "Project",
"status": "Available",
"type": "String",
"usePreDefinedValuesOnly": true
}
Exemplo 3: adicionar um atributo de segurança personalizado com uma lista de valores predefinidos
Eis um exemplo que adiciona uma nova definição de atributo de segurança personalizada com uma lista de valores predefinidos como uma coleção de cadeias.
- Conjunto de atributos:
Engineering
- Atributo:
Project
- Tipo de dados de atributo: Coleção de cadeias de caracteres
- Valores predefinidos:
Alpine
, , Baker
Cascade
Solicitação
O exemplo a seguir mostra uma solicitação.
POST https://graph.microsoft.com/beta/directory/customSecurityAttributeDefinitions
Content-Type: application/json
{
"attributeSet": "Engineering",
"description": "Active projects for user",
"isCollection": true,
"isSearchable": true,
"name": "Project",
"status": "Available",
"type": "String",
"usePreDefinedValuesOnly": true,
"allowedValues": [
{
"id": "Alpine",
"isActive": true
},
{
"id": "Baker",
"isActive": true
},
{
"id": "Cascade",
"isActive": true
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new CustomSecurityAttributeDefinition
{
AttributeSet = "Engineering",
Description = "Active projects for user",
IsCollection = true,
IsSearchable = true,
Name = "Project",
Status = "Available",
Type = "String",
UsePreDefinedValuesOnly = true,
AllowedValues = new List<AllowedValue>
{
new AllowedValue
{
Id = "Alpine",
IsActive = true,
},
new AllowedValue
{
Id = "Baker",
IsActive = true,
},
new AllowedValue
{
Id = "Cascade",
IsActive = true,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.CustomSecurityAttributeDefinitions.PostAsync(requestBody);
mgc-beta directory custom-security-attribute-definitions create --body '{\
"attributeSet": "Engineering",\
"description": "Active projects for user",\
"isCollection": true,\
"isSearchable": true,\
"name": "Project",\
"status": "Available",\
"type": "String",\
"usePreDefinedValuesOnly": true,\
"allowedValues": [\
{\
"id": "Alpine",\
"isActive": true\
},\
{\
"id": "Baker",\
"isActive": true\
},\
{\
"id": "Cascade",\
"isActive": true\
}\
]\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomSecurityAttributeDefinition()
attributeSet := "Engineering"
requestBody.SetAttributeSet(&attributeSet)
description := "Active projects for user"
requestBody.SetDescription(&description)
isCollection := true
requestBody.SetIsCollection(&isCollection)
isSearchable := true
requestBody.SetIsSearchable(&isSearchable)
name := "Project"
requestBody.SetName(&name)
status := "Available"
requestBody.SetStatus(&status)
type := "String"
requestBody.SetType(&type)
usePreDefinedValuesOnly := true
requestBody.SetUsePreDefinedValuesOnly(&usePreDefinedValuesOnly)
allowedValue := graphmodels.NewAllowedValue()
id := "Alpine"
allowedValue.SetId(&id)
isActive := true
allowedValue.SetIsActive(&isActive)
allowedValue1 := graphmodels.NewAllowedValue()
id := "Baker"
allowedValue1.SetId(&id)
isActive := true
allowedValue1.SetIsActive(&isActive)
allowedValue2 := graphmodels.NewAllowedValue()
id := "Cascade"
allowedValue2.SetId(&id)
isActive := true
allowedValue2.SetIsActive(&isActive)
allowedValues := []graphmodels.AllowedValueable {
allowedValue,
allowedValue1,
allowedValue2,
}
requestBody.SetAllowedValues(allowedValues)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
customSecurityAttributeDefinitions, err := graphClient.Directory().CustomSecurityAttributeDefinitions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
CustomSecurityAttributeDefinition customSecurityAttributeDefinition = new CustomSecurityAttributeDefinition();
customSecurityAttributeDefinition.setAttributeSet("Engineering");
customSecurityAttributeDefinition.setDescription("Active projects for user");
customSecurityAttributeDefinition.setIsCollection(true);
customSecurityAttributeDefinition.setIsSearchable(true);
customSecurityAttributeDefinition.setName("Project");
customSecurityAttributeDefinition.setStatus("Available");
customSecurityAttributeDefinition.setType("String");
customSecurityAttributeDefinition.setUsePreDefinedValuesOnly(true);
LinkedList<AllowedValue> allowedValues = new LinkedList<AllowedValue>();
AllowedValue allowedValue = new AllowedValue();
allowedValue.setId("Alpine");
allowedValue.setIsActive(true);
allowedValues.add(allowedValue);
AllowedValue allowedValue1 = new AllowedValue();
allowedValue1.setId("Baker");
allowedValue1.setIsActive(true);
allowedValues.add(allowedValue1);
AllowedValue allowedValue2 = new AllowedValue();
allowedValue2.setId("Cascade");
allowedValue2.setIsActive(true);
allowedValues.add(allowedValue2);
customSecurityAttributeDefinition.setAllowedValues(allowedValues);
CustomSecurityAttributeDefinition result = graphClient.directory().customSecurityAttributeDefinitions().post(customSecurityAttributeDefinition);
const options = {
authProvider,
};
const client = Client.init(options);
const customSecurityAttributeDefinition = {
attributeSet: 'Engineering',
description: 'Active projects for user',
isCollection: true,
isSearchable: true,
name: 'Project',
status: 'Available',
type: 'String',
usePreDefinedValuesOnly: true,
allowedValues: [
{
id: 'Alpine',
isActive: true
},
{
id: 'Baker',
isActive: true
},
{
id: 'Cascade',
isActive: true
}
]
};
await client.api('/directory/customSecurityAttributeDefinitions')
.version('beta')
.post(customSecurityAttributeDefinition);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\CustomSecurityAttributeDefinition;
use Microsoft\Graph\Beta\Generated\Models\AllowedValue;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CustomSecurityAttributeDefinition();
$requestBody->setAttributeSet('Engineering');
$requestBody->setDescription('Active projects for user');
$requestBody->setIsCollection(true);
$requestBody->setIsSearchable(true);
$requestBody->setName('Project');
$requestBody->setStatus('Available');
$requestBody->setType('String');
$requestBody->setUsePreDefinedValuesOnly(true);
$allowedValuesAllowedValue1 = new AllowedValue();
$allowedValuesAllowedValue1->setId('Alpine');
$allowedValuesAllowedValue1->setIsActive(true);
$allowedValuesArray []= $allowedValuesAllowedValue1;
$allowedValuesAllowedValue2 = new AllowedValue();
$allowedValuesAllowedValue2->setId('Baker');
$allowedValuesAllowedValue2->setIsActive(true);
$allowedValuesArray []= $allowedValuesAllowedValue2;
$allowedValuesAllowedValue3 = new AllowedValue();
$allowedValuesAllowedValue3->setId('Cascade');
$allowedValuesAllowedValue3->setIsActive(true);
$allowedValuesArray []= $allowedValuesAllowedValue3;
$requestBody->setAllowedValues($allowedValuesArray);
$result = $graphServiceClient->directory()->customSecurityAttributeDefinitions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
attributeSet = "Engineering"
description = "Active projects for user"
isCollection = $true
isSearchable = $true
name = "Project"
status = "Available"
type = "String"
usePreDefinedValuesOnly = $true
allowedValues = @(
@{
id = "Alpine"
isActive = $true
}
@{
id = "Baker"
isActive = $true
}
@{
id = "Cascade"
isActive = $true
}
)
}
New-MgBetaDirectoryCustomSecurityAttributeDefinition -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.custom_security_attribute_definition import CustomSecurityAttributeDefinition
from msgraph_beta.generated.models.allowed_value import AllowedValue
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CustomSecurityAttributeDefinition(
attribute_set = "Engineering",
description = "Active projects for user",
is_collection = True,
is_searchable = True,
name = "Project",
status = "Available",
type = "String",
use_pre_defined_values_only = True,
allowed_values = [
AllowedValue(
id = "Alpine",
is_active = True,
),
AllowedValue(
id = "Baker",
is_active = True,
),
AllowedValue(
id = "Cascade",
is_active = True,
),
],
)
result = await graph_client.directory.custom_security_attribute_definitions.post(request_body)
Resposta
O exemplo a seguir mostra a resposta.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#directory/customSecurityAttributeDefinitions/$entity",
"attributeSet": "Engineering",
"description": "Active projects for user",
"id": "Engineering_Project",
"isCollection": true,
"isSearchable": true,
"name": "Project",
"status": "Available",
"type": "String",
"usePreDefinedValuesOnly": true
}