Hi @Renezeder Markus
The customSecurityAttributes
is not a basic property and it is only returned in beta versions, so make sure your project downloads the graph beta package. Referring to my code, I've tested it locally and it works fine.
dotnet add package Microsoft.Graph.Beta --version 5.22.0-preview
using Azure.Identity;
using Microsoft.Graph.Beta;
using Microsoft.Graph.Models.ODataErrors;
using Newtonsoft.Json;
var scopes = new[] { "https://graph.microsoft.com/.default" };
var tenantId = "{tenant id}";
// Values from app registration
var clientId = "{client id}";
var clientSecret = "{client secret}";
// using Azure.Identity;
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
// https://docs.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret, options);
GraphServiceClient graphServiceClient = new GraphServiceClient(clientSecretCredential, scopes);
try
{
var user = await graphServiceClient.Users["2b430883-a319-4218-837f-fa774724ff81"].GetAsync(
requestConfiguration =>
{
requestConfiguration.QueryParameters.Select = new string[] { "customSecurityAttributes" };
}
);
Console.WriteLine(JsonConvert.SerializeObject(user));
}
catch (ODataError odataError)
{
Console.WriteLine(odataError.Error.Code);
Console.WriteLine(odataError.Error.Message);
}
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.