将一个 Asp.net Membership 数据库与多个应用程序一起使用 Single Sign On [英] Using one Asp.net Membership database with multiple applications Single Sign On

查看:27
本文介绍了将一个 Asp.net Membership 数据库与多个应用程序一起使用 Single Sign On的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台 IIS 服务器上有两个 asp.net 应用程序,我想使用相同的后端 asp_security 数据库和成员资格提供程序.我已经读到我所要做的就是在两个 Web 配置中引用相同的应用程序名称,就像我现在所做的那样,但我一定是做错了什么

I have two asp.net applications on one IIS server and I would like to use the same back end asp_security database and membership provider. I've read that all I have to do is reference the same application name in both web configs as I'm doing now, but I must be doing something wrong

在每个应用程序 web.config 中,我都有这个部分.

In each applications web.config I have this section.

<membership>
  <providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider"
              type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
              connectionStringName="membership"
              enablePasswordRetrieval="false"
              enablePasswordReset="true"
              requiresQuestionAndAnswer="false"
              applicationName="/"
              requiresUniqueEmail="false"
              minRequiredPasswordLength="5"
              minRequiredNonalphanumericCharacters="0"
              passwordFormat="Hashed"
              maxInvalidPasswordAttempts="5"
              passwordAttemptWindow="10"
              passwordStrengthRegularExpression=""
              />
  </providers>
</membership>

当我从应用程序 A 登录并浏览到应用程序 B 时,应用程序 B 似乎对我或我从应用程序 A 获得的凭据一无所知.有人知道我做错了什么吗?

When I log in from application A and browse to application B application B doesn't seem to know anything about me or my credentials from application A. Anyone have any ideas what I'm doing incorrectly?

推荐答案

只是为了结束,我将回答我是如何实现我最初的问题所要求的目标的.

Just for closure sake I will answer how I did achieved the goal of what my original question meant to ask for.

我在一台 IIS 服务器上有两个 asp.net 应用程序.我的目标是当用户登录 app1 时,他们的用户凭据将在 app2 中可用.配置 asp.net 成员资格提供程序只是我正在寻找的一步.即使两个应用程序都使用相同的后端数据库和提供程序,当我点击 app2 时,我仍然无法通过身份验证.我正在寻找的是单点登录解决方案.

I had two asp.net applications on one IIS server. It was my goal to make it so when user logged onto app1 their user credentials would be available in app2. Configuring the asp.net membership provider is only one step of what I was looking for. Even if both apps were using the same back end database and provider I still wouldn't be authenticated when I hit app2. What I was looking for was a Single Sign On solution.

一旦您将两个应用程序都指向您的 asp_membership 数据库,将以下内容放在您的网络配置的 system.web 部分

Once you have both apps pointing at your asp_membership database by placing the following in the system.web section of your web config

<authentication mode="Forms" />
<membership>
  <providers>
    <clear/>
    <add name="AspNetSqlMembershipProvider"
              type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
              connectionStringName="membership"
              applicationName="/"
              />
  </providers>
</membership>
<roleManager enabled="true" />

确保两者具有相同的 applicationname 属性集.

make sure both have the same applicationname property set.

我使用的是 IIS 6,因此我将其配置为为两个应用程序自动生成机器密钥.因为这两个应用程序都运行在同一台机器上,所以密钥是相同的,这是使 SSO 工作的关键部分.设置 IIS 后,将以下内容添加到我的 web.config

I was using IIS 6 so I configured it to autogenerate a machine key for both applications. Because both of these applications live on the same machine the key would be identical, this is the critical part to making the SSO work. After setting up IIS the following was added to my web.config

    <machineKey decryptionKey="AutoGenerate" validation="SHA1" validationKey="AutoGenerate" />

这就是它的全部内容.完成后,我可以登录 app1,然后浏览到 app2 并保留我的安全凭据.

That was all there was to it. Once that was done I could log into app1 and then browse to app2 and keep my security credentials.

感谢您朝着正确的方向努力.

Thanks for the push in the right direction.

这篇关于将一个 Asp.net Membership 数据库与多个应用程序一起使用 Single Sign On的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆