一、站点结构

n  http://www.test.com/:test主站

n  space.test.comspace子站

n  edu.test.com:平台子站

二、认证处理

n  所有站点采用Forms认证,站点下和下面的虚拟上当web.config加以下配置

<-- 这个结点是阻止匿名用户访问根据各个情况配置,也可指定各个位置具体配置 -->

    <authorization>

      <deny users="?" />

</authorization>

    <machineKey

validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"

    decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"

    validation="SHA1" />

    <authentication mode="Forms">

      <forms loginUrl="http:// www. test.com/ " domain="test.com" name="test "></forms>

    </authentication>

n  所有的主站和子站登录页都是http:// www. test.com/test主站的首页)

登录页处理登录参考以下代码:

              if (CheckLogin(**,**))

         {

                  FormsAuthentication.RedirectFromLoginPage(uin, true);

}

如果test用户没有开通sns账号则先开通后调用

FormsAuthentication.RedirectFromLoginPage(uin, true);

n  所有的主站和子站当前登录用户都从System.Security.Principal.IPrincipal类型UserUser.Identity.IsAuthenticated 来判断用户是否登录

User.Identity.Name来取得已经登录的Uin构造针对各自站点的当前用户Session

n  各站点退出参考以下代码:

FormsAuthentication.SignOut();

FormsAuthentication.RedirectToLoginPage();

posted on 2009-06-25 20:20  collinye  阅读(412)  评论(1编辑  收藏  举报