7.1 使用Windows身份验证的原因
使用Windows身份验证的原因
1 需要完成的工作很好
2 集成IIS安全性
3 集成Windows客户机
我们不希望使用Windows身份验证的原因又是什么呢?
1 仅限于Windows用户
2 仅限Windows客户机
3 缺乏灵活性
7.2 Windows身份验证的工作方式
1 基本身份验证
2 摘要身份验证
3 集成Windows身份验证
基本身份验证用户名和密码以明文传输,基于这个原因基本身份验证只能和HTTP线路加密工具如SSL一起使用。
摘要身份验证传输的是密码的摘要
7.3 ASP.NET Windows 身份验证API
7.3.1 WindowsAuthenticationModule类
7.4 实现Windows身份验证
1. 配置IIS执行身份验证
2. 配置ASP.NET使用IIS身份验证信息
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<complilation defaultLanguage="c#" debug="true"/>
<customErrors mode="Off"/>
<authentication mode="windows"/>
</system.web>
</configuration>
7.4.3访问ASP.NET中的Windows用户信息
7.44 自定义Windows身份验证
private void Button1_Click(object sender, System.EventArgs e)
{
FileStream fs=new FileStream(Server.MapPath("")+@"/IOLog.txt",FileMode.Append);
string ip=DateTime.Now.ToString()+" "+Request.UserHostAddress.ToString()+",";
byte[] b=System.Text.Encoding.ASCII.GetBytes(ip);
fs.Write(b,0,b.Length);
fs.Close();
Response.Write("日志写入成功!");
}