配置文件卡属性对应于 Microsoft Entra ID 中的属性。 将属性作为 profileCardProperty 添加到组织的 profileCardProperties 集合中将配置文件卡配置为显示属性值。 从集合中删除 profileCardProperty不会从 Microsoft Entra ID 中删除属性;它会删除配置,以便配置文件卡不再显示属性值。
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new ProfileCardProperty
{
DirectoryPropertyName = "CustomAttribute1",
Annotations = new List<ProfileCardAnnotation>
{
new ProfileCardAnnotation
{
DisplayName = "Cost Center",
Localizations = new List<DisplayNameLocalization>
{
new DisplayNameLocalization
{
LanguageTag = "ru",
DisplayName = "центр затрат",
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Admin.People.ProfileCardProperties.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ProfileCardProperty profileCardProperty = new ProfileCardProperty();
profileCardProperty.setDirectoryPropertyName("CustomAttribute1");
LinkedList<ProfileCardAnnotation> annotations = new LinkedList<ProfileCardAnnotation>();
ProfileCardAnnotation profileCardAnnotation = new ProfileCardAnnotation();
profileCardAnnotation.setDisplayName("Cost Center");
LinkedList<DisplayNameLocalization> localizations = new LinkedList<DisplayNameLocalization>();
DisplayNameLocalization displayNameLocalization = new DisplayNameLocalization();
displayNameLocalization.setLanguageTag("ru");
displayNameLocalization.setDisplayName("центр затрат");
localizations.add(displayNameLocalization);
profileCardAnnotation.setLocalizations(localizations);
annotations.add(profileCardAnnotation);
profileCardProperty.setAnnotations(annotations);
ProfileCardProperty result = graphClient.admin().people().profileCardProperties().post(profileCardProperty);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.profile_card_property import ProfileCardProperty
from msgraph.generated.models.profile_card_annotation import ProfileCardAnnotation
from msgraph.generated.models.display_name_localization import DisplayNameLocalization
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ProfileCardProperty(
directory_property_name = "CustomAttribute1",
annotations = [
ProfileCardAnnotation(
display_name = "Cost Center",
localizations = [
DisplayNameLocalization(
language_tag = "ru",
display_name = "центр затрат",
),
],
),
],
)
result = await graph_client.admin.people.profile_card_properties.post(request_body)