问题描述
嗨,我正在使用Microsoft.Xrm.Sdk.Client中的IServiceManagement类来尝试对Dynamics用户进行身份验证,如文档https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/sample-authenticate-users-web-services中的本示例所述。
if (serviceManagement.AuthenticationType !=
AuthenticationProviderType.ActiveDirectory)
{
AuthenticationCredentials tokenCredentials =
serviceManagement.Authenticate(authCredentials);
// Obtain discovery/organization service proxy for Federated,LiveId and OnlineFederated environments.
// Instantiate a new class of type using the 2 parameter constructor of type IServiceManagement and SecurityTokenResponse.
return (TProxy)classtype
.GetConstructor(new Type[] { typeof(IServiceManagement<TService>),typeof(SecurityTokenResponse) })
.Invoke(new object[] { serviceManagement,tokenCredentials.SecurityTokenResponse });
}
当用户凭据运行正常时,此方法效果很好,但是我无法找到如何在身份验证调用中获取实际错误消息的方法。当Authenticate调用引发异常时,它只会引发FaultException并带有通用的“ Authentication Failed”错误消息。
但是,当我查看正在进行的网络调用时,确实看到对/RST2.srf端点的调用,并在响应中显示一条错误消息,如:
(简短消息)
The user account {EmailHidden} does not exist in the test.com directory. To sign into this application,the account must be added to the directory
我想知道是否有任何方法可以使用IServiceManagement类从/RST2.srf调用中获取该错误消息。
感谢您的帮助!谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)