AAD Graph 客户端:创建长度大于 120 个字符的 AD 组

AAD Graph client: Creating AD group with length greater than 120 chars

当我调用 _activeDirectoryClient.Groups.AddGroupAsync(group) 其中组的显示名称大于 120 个字符时,它会抛出以下异常:

Microsoft.Data.OData.ODataErrorException: Unsupported or invalid query filter clause specified for property 'displayName' of resource 'Group'. ---> System.Data.Services.Client.DataServiceQueryException: An error occurred while processing this request. ---> System.Data.Services.Client.DataServiceClientException: {"odata.error":{"code":"Request_UnsupportedQuery","message":{"lang":"en","value":"Unsupported or invalid query filter clause specified for property 'displayName' of resource 'Group'."}}} at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult) at System.Data.Services.Client.QueryResult.EndExecuteQuery[TElement](Object source, String method, IAsyncResult asyncResult)

PS:我在 Microsoft Graph github 中问过这个问题。但是,有人告诉我 post 在这里。

我认为错误不是由 AddGroupAsync 函数引起的,如果组的显示名称超过其允许的长度,它将抛出以下错误:

Invalid value specified for property 'displayName' of resource 'Group'.

您的错误似乎是显示名称 属性 上的查询过滤器无效,经过测试,当在显示名称 属性 上使用查询过滤器时(长度大于 120 个字符):

https://graph.windows.net/xxxxx.onmicrosoft.com/groups?$filter=displayName eq 'xxxxxxx'&api-version=1.6

它显示了与您相同的错误,服务器端似乎限制了属性过滤器的长度。如果你想要 azure ad graph api 支持,你可以发送反馈 here