Microsoft.Xrm.Sdk.Client IServiceManagement如何获取实际的身份验证错误消息

问题描述

嗨,我正在使用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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...