我们在.NET Core2.1上运行,有时在运行以下查询时会得到异常“此平台不支持安全二进制序列化”:
await _adClient.Users[userId].AppRoleAssignments.ExecuteAsync();重新执行查询通常有效,因此满足了二进制序列化不尝试(或成功?)的某些条件。在以后的请求中?也就是说,如果我重新启动服务,它通常也会处理第一个请求。
我们使用旧的AD图客户端是因为: 1) Microsoft还不完全支持AppRoleAssignments;2)支持的是beta的一部分,不推荐用于生产。
下面是完整的调用堆栈:
System.Data.Services.Client.BaseAsyncResult.EndExecute<T>(object source, string method, IAsyncResult asyncResult)
System.Data.Services.Client.QueryResult.EndExecuteQuery<TElement>(object source, string method, IAsyncResult asyncResult)
System.Data.Services.Client.DataServiceRequest.EndExecute<TElement>(object source, DataServiceContext context, string method, IAsyncResult asyncResult)
System.Data.Services.Client.DataServiceQuery<TElement>.EndExecute(IAsyncResult asyncResult)
Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.DataServiceContextWrapper+<>c__DisplayClass4c<TSource, TInterface>.<ExecuteAsync>b__4a(IAsyncResult r)
System.Threading.Tasks.TaskFactory<TResult>.FromAsyncCoreLogic(IAsyncResult iar, Func<IAsyncResult, TResult> endFunction, Action<IAsyncResult> endAction, Task<TResult> promise, bool requiresSynchronization)
Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.DataServiceContextWrapper.ExecuteAsync<TSource, TInterface>(DataServiceQuery<TSource> inner)
Microsoft.Azure.ActiveDirectory.GraphClient.AppRoleAssignmentCollection.<ExecuteAsync>b__2()
Merck.SeaMonkey.Api.AzureADApi.Controllers.UserController.GetApplicationRoleAssignments(string userId) in UserController.cs新的Microsoft Graph在这里不是一个选项,尽管我想我们可以降到基本REST接口,这是一些工作,所有重试逻辑,结果解析,等等,我们依赖于图形客户端所做的。
更新:给出异常的来源,我们假设在序列化OData响应中的实体时会出现问题。但是,使用AD图资源管理器,我们可以看到空值数组的一个非常简单的响应,以及实体元数据文档的链接。我们经常通过删除和添加新的应用程序角色分配来使问题再次出现,但我们不能强迫它100%可靠地发生。它看起来像是某种状态被破坏了,也许是在某个内部缓存中?
发布于 2018-11-15 01:11:30
我经常使用这个api调用--但是我对旧图使用了一个直接rest httpClient调用。
我只是将此作为参考-注意在url (1.6)上的显式版本。我还发布了我反序列化到的对象,这可能与官方对象模式不匹配。
// OLD Graph End point // like ... https://graph.windows.net/{tenant-id}/users/{id}/appRoleAssignments?api-version=1.6
urlUserInviteToUse = "https://graph.windows.net/" + m_CfgHlp.TenIdInB2C + "/" + ObjFamilyName + "/" + DirObjIdToGet + "/" + ObjFunctionCall + "?api-version=1.6";由于rest字符串有效负载,我正在有效地使用JsonConvert.DeserializeObject从有效负载转到对象类。请注意,日期未被反序列化为日期。
public class AppRoleAssignmentsRoot
{
public string odatametadata { get; set; }
public AppRoleAssignment[] value { get; set; }
}
public class AppRoleAssignment
{
public string odatatype { get; set; }
public string objectType { get; set; }
public string objectId { get; set; }
public object deletionTimestamp { get; set; }
public object creationTimestamp { get; set; }
public string id { get; set; }
public string principalDisplayName { get; set; }
public string principalId { get; set; }
public string principalType { get; set; }
public string resourceDisplayName { get; set; }
public string resourceId { get; set; }
}https://stackoverflow.com/questions/53209875
复制相似问题