zoukankan      html  css  js  c++  java
  • Intranet user windows Authentication, external user Form Authentication

    经常有这样的需求,一个web application 公司内部域用户访问时自动登录,外部用户访问时需要提供用户名和密码用Form登录。

    1. 在web项目中新建  WinLogin.aspx, WebLogin.aspx,Redirect401.htm

    在Redirect401.htm中添加javascript 代码将页面跳转到WebLogin.aspx上 

    2. 将web application的web.config配置成form登录

      <authentication mode="Forms">
                <forms  loginUrl="Winlogin.aspx"  ></forms>
          </authentication>

    3. pulish到iis上后 打开IIS Manager right-click WinLogin.aspx -> properities -> File Security tab ->edit the authenticaion

    un-check Enable anonymous access and check Integrated Windows authentication

    4. 在IIS Manager中 right-click WebLogin.aspx -> properities -> File Security tab ->edit the authenticaion. only check enable anonymous access

    5. make sure 打开IE -> internet options ->security ->custom level -> user authentication the "automatic logon only int Intranet zone" or "automatic logon with current user name and password" checked

    6. 打开IIs manager right-click the web application -> properities -> custom errors reset 401 httperrors contents direct to  Redirect401.htm

    7. 用户访问web application时页面会跳转带 Winlogin.aspx,如果该用户是域用户会自动登录,如果是外部用户ie会弹出登录框。外部用户登录失败或者或者取消登录时会产生http 401 error 进而跳转到Redirect401.htm,而Redirect401.htm中的javascript code 又将页面跳转到WebLogin.aspx,因为WebLogin.aspx在iis中设置成可以匿名访问所以就不会自动跳转了。

     参考自 http://msdn.microsoft.com/en-us/library/ms972958.aspx



  • 相关阅读:
    asp.net c#中去掉最后一个字符和去掉第一个字母
    两个div并排
    VS.Net2005中使用本地化功能实现多语言的切换
    gridview嵌套DropDownList選定值[转]
    C# 获取系统时间
    NERDTree,好用的文件浏览器
    通过$.browser来判断浏览器
    vim 智能提示
    让vim显示函数列表
    vim中文乱码解决方法
  • 原文地址:https://www.cnblogs.com/kting/p/2272336.html
Copyright © 2011-2022 走看看