名前空間: microsoft.graph
新しい customSecurityAttributeDefinition オブジェクトを作成します。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
CustomSecAttributeDefinition.ReadWrite.All |
注意事項なし。 |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
CustomSecAttributeDefinition.ReadWrite.All |
注意事項なし。 |
重要
職場または学校アカウントを使用した委任されたシナリオでは、サインインしているユーザーに、サポートされているMicrosoft Entraロールまたはサポートされているロールのアクセス許可を持つカスタム ロールを割り当てる必要があります。
属性定義管理者 は、この操作でサポートされる唯一の特権ロールです。
既定では、 グローバル管理者 とその他の管理者ロールには、カスタム セキュリティ属性の読み取り、定義、または割り当てに対するアクセス許可がありません。
HTTP 要求
POST /directory/customSecurityAttributeDefinitions
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
Content-Type |
application/json. 必須です。 |
要求本文
要求本文で、 customSecurityAttributeDefinition オブジェクトの JSON 表現を指定します。
次の表は、 customSecurityAttributeDefinition を作成するときに構成できるプロパティを示しています。
プロパティ |
型 |
説明 |
attributeSet |
String |
属性セットの名前。 大文字と小文字が区別されます。 必須です。 |
説明 |
String |
カスタム セキュリティ属性の説明。 最大 128 文字の長さと Unicode 文字を含めることができます。 スペースまたは特殊文字を含めることはできません。 後で変更できます。 省略可能。 |
isCollection |
ブール型 |
カスタム セキュリティ属性に複数の値を割り当てることができるかどうかを示します。 後で変更することはできません。
type が にBoolean 設定されている場合、isCollection を にtrue 設定することはできません。 必須です。 |
isSearchable |
ブール型 |
属性値が割り当てられているオブジェクトを検索するために、カスタム セキュリティ属性値にインデックスを作成するかどうかを示します。 後で変更することはできません。 必須です。 |
name |
String |
カスタム セキュリティ属性の名前。 属性セット内で一意である必要があります。 最大 32 文字の長さと Unicode 文字を含めることができます。 スペースまたは特殊文字を含めることはできません。 後で変更することはできません。 大文字と小文字が区別されます。 必須です。 |
status |
String |
カスタム セキュリティ属性がアクティブか非アクティブかを指定します。 許容される値は Available と Deprecated です。 後で変更できます。 必須です。 |
type |
String |
カスタム セキュリティ属性値のデータ型。 サポートされる型は、 Boolean 、、 Integer および String です。 後で変更することはできません。 必須です。 |
usePreDefinedValuesOnly |
ブール型 |
定義済みの値のみをカスタム セキュリティ属性に割り当てることができるかどうかを示します。 に設定すると false 、自由形式の値が許可されます。 後で から にfalse 変更できますが、 から true false にtrue 変更することはできません。
型が にBoolean 設定されている場合、usePreDefinedValuesOnly を にtrue 設定することはできません。 必須です。 |
id プロパティは自動生成され、設定できません。
応答
成功した場合、このメソッドは 201 Created
応答コードと、応答本文に customSecurityAttributeDefinition オブジェクトを返します。
例
例 1: カスタム セキュリティ属性を追加する
次の例では、String 型の単一の自由形式の値である新しいカスタム セキュリティ属性定義を追加します。
- 属性セット:
Engineering
- 属性:
ProjectDate
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/v1.0/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.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);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
mgc 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\
}\
'
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// 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"
graphmodels "github.com/microsoftgraph/msgraph-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)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// 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);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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')
.post(customSecurityAttributeDefinition);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\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();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
attributeSet = "Engineering"
description = "Target completion date"
isCollection = $false
isSearchable = $true
name = "ProjectDate"
status = "Available"
type = "String"
usePreDefinedValuesOnly = $false
}
New-MgDirectoryCustomSecurityAttributeDefinition -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.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)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
次の例は応答を示しています。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$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
}
例 2: 複数の定義済み値をサポートするカスタム セキュリティ属性を追加する
次の例では、定義済みの String 型の複数の値をサポートする新しいカスタム セキュリティ属性定義を追加します。
- 属性セット:
Engineering
- 属性:
Project
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/v1.0/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.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);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
mgc 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\
}\
'
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// 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"
graphmodels "github.com/microsoftgraph/msgraph-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)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// 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);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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')
.post(customSecurityAttributeDefinition);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\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();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
attributeSet = "Engineering"
description = "Active projects for user"
isCollection = $true
isSearchable = $true
name = "Project"
status = "Available"
type = "String"
usePreDefinedValuesOnly = $true
}
New-MgDirectoryCustomSecurityAttributeDefinition -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.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)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
次の例は応答を示しています。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$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
}
例 3: 定義済みの値の一覧を含むカスタム セキュリティ属性を追加する
次の例では、定義済みの値の一覧を String のコレクションとして含む新しいカスタム セキュリティ属性定義を追加します。
- 属性セット:
Engineering
- 属性:
Project
- 属性データ型: 文字列のコレクション
- 定義済みの値:
Alpine
、、 Baker
。 Cascade
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/v1.0/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.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);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
mgc 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\
}\
]\
}\
'
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// 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"
graphmodels "github.com/microsoftgraph/msgraph-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)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// 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);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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')
.post(customSecurityAttributeDefinition);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\CustomSecurityAttributeDefinition;
use Microsoft\Graph\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();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.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-MgDirectoryCustomSecurityAttributeDefinition -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.custom_security_attribute_definition import CustomSecurityAttributeDefinition
from msgraph.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)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
次の例は応答を示しています。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$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
}