首页 > 解决方案 > 作为 ClaimsIdentity 的 HttpContext.User.Identity 为空

问题描述

我创建了一个 MVC 应用程序来使用 Sustainsys 集成 ADFS SSO。它在我的测试开发服务器中工作,但是当我尝试将它部署到不同的 IIS 服务器时。

工作应用程序在 Windows Server 2016 的 IIS 10 中部署。我被告知该 Web 服务器有一个 AD 服务器 linekd。我的 mvc 应用程序按预期工作正常,登录 adfs 后正在检索声明。这是一个测试开发服务器,所以我不能使用它,我得到了另一个开发服务器,我需要在其中部署 mvc 应用程序。

此服务器是 windows 2019,它没有附加任何 AD 服务器。我部署了 mvc 应用程序,就像我在另一台服务器中部署的方式一样,当我测试我的应用程序时,声明 ( HttpContext.User.Identity) 为空。MVC 应用程序已在 ADFS 服务器中受信任。

在 web 配置中,我有 authentication = forms,它是我在sustainsys文档中遵循的设置。

我不确定我需要做什么配置才能使其工作,它与代码无关,因为它在本地工作并且在我部署到的第一台服务器中工作。

编辑:我有返回属性的 SAML 响应,

  <AttributeStatement>
            <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
                <AttributeValue>value</AttributeValue>
            </Attribute>
            <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
                <AttributeValue>value</AttributeValue>
            </Attribute>
            <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn">
                <AttributeValue>value</AttributeValue>
            </Attribute>
            <Attribute Name="Department">
                <AttributeValue>Search</AttributeValue>
            </Attribute>
        </AttributeStatement>

标签: asp.net-mvciisasp.net-identityadfs

解决方案


推荐阅读