OJB1
OJB1

Reputation: 2785

Azure AD - List schemaExtensions for my own tenant ONLY using MS Graph SDK

I'm working through the dreaded MS Docs whilst figuring out how to create and list schema extensions created for my own tenant.

List schemaExtensions

MS Docs provide an example in how to list the schema extensions through the MS Graph SDK, however the results return extensions from other devs and Apps. The MS notes actually do advise the following:

Note: The list will also contain schema extension definitions (marked as Available) created by other developers from other tenants. This is different from other APIs that only return tenant-specific data. Extension data created based on schema extension definitions is tenant-specific and can only be accessed by apps explicitly granted permission.

Firstly, why on earth would I want to list extensions created by other people? I just want to list extensions created for my own app/tenant but don't understand how to do this? I can't find an example for Graph SDK that shows how to return results only for extensions I created myself.

So far am using the MS example from the above link, of which a generic list results of results return over 100qty different extensions from every man and his dog!

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var schemaExtensions = await graphClient.SchemaExtensions
    .Request()
    //.Filter("id eq 'graphlearn_test'") // this would only work for returning one particular extension, I want to list all extensions created only for my own app/tenant
    .GetAsync();

Upvotes: 1

Views: 235

Answers (1)

user2250152
user2250152

Reputation: 20660

During creation of an extension, you can specify the owner property which is an appId of the application that is the owner of the schema extension.

By default, the calling application's appId will be set as the owner. However, the property may be supplied on creation, to set the owner appId to something different from the calling app. Once set, this property is read-only and cannot be changed.

Then you can filter the extensions by the owner property.

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var schemaExtensions = await graphClient.SchemaExtensions
    .Request()
    .Filter("owner eq 'your_app_id'")
    .GetAsync();

Upvotes: 1

Related Questions