我有一个远程的WCF服务,托管在IIS上。然后我有一个托管在Azure Websites上的ASP.NET MVC网站。
该网站使用Azure Active Directory对用户进行身份验证,并且它可以正常工作。然而,WCF服务需要正确的Windows(基于域)凭据才能返回结果。
当我在我的ASP.NET MVC应用程序中实例化服务时,我正在使用:
SomeService.ServiceClient client = new ServiceClient ("SOAP");
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
这是由
Web.config
文件支持的:<basicHttpBinding>
<binding name="SOAP" allowCookies="true" maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
当我在本地运行时,它可以正常工作——我从本地AppPool中获取凭据,这些凭据有效用于访问WCF服务。然而,一旦我将网站部署到Azure上,由于显然服务不知道我本地的凭据,上述方法就会失效。
问题:
有没有办法通过浏览器向WCF服务传递Windows凭据,而不破坏AAD auth栈,因为我只需要这些凭据来进行WCF连接,而不需要其他任何东西?我非常乐意显示一个系统提示框以输入凭据。