Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
505 views
in Technique[技术] by (71.8m points)

asp.net core webapi - Microsoft Graph API - generate the filter query for the extension attribute

I have create a extension/Custom attribute called extensions_{b2cextensionappid}_IsDemoAccount in the Azure AD B2C to flag the user is a demo user.

I have tried to create filter query to select all the demo users in the Azure AD B2C directory using GraphServiceClient in dotnet core API. But it is not working.

   var result = await graphClient.Users
            .Request()
            //.Filter($"identities/any(c:c/issuerAssignedId eq 'test2' and c/issuer eq '{config.Value.TenantId}')")
            .Filter($"Extensions/any(c:c/{IsTemporaryAccount} eq true')")
            .Expand("Extensions")

Is there any way to generate the filter query for the extension attribute? I did not find any samples in the Microsoft documentation.

Please provide any solutions or an reference to achieve this?

question from:https://stackoverflow.com/questions/65644603/microsoft-graph-api-generate-the-filter-query-for-the-extension-attribute

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You confuse Create extensionProperty and Create open extension.

extension_{b2cextensionappid}_IsDemoAccount is actually extensionProperty rather than open extension.

So you should use the following code to filter users.

        var users = await graphClient.Users
        .Request()
        .Filter($"extension_{b2cextensionappid}_IsDemoAccount eq true")
        .GetAsync();

Please note the extension property should be extension_**_** rather than extensions_**_**.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...