您的位置:首页 > 编程语言

分别用(Windows/Form/Soap/WebService)实现用户身份验证(含示例代码下载)

2007-12-14 11:50 966 查看
2005年12月31日 22:36:00
(一).Windows集成身份验证的实现
1. 说明:
Windows身份验证是利用Windows现有的账号信息来进行身份验证.
由IIS自动提供身份验证,比自定义身份验证更安全,但没有自定义身份验证灵活.
适用于Web内部应用程序.
在Web.Config中配置: >authentication mode="Windows" /<
2.代码示例下载:
http://www.cnitblog.com/Files/ChengKing/WindowsAuth.rar
(二).Form身份验证
1.说明: 使用基于窗体的验证方式. 在Web.Config中配置:
>authentication mode="Forms"<
>forms name=".ASPXCOOKIEDEMO"
protection="All"
loginUrl="login.aspx"
timeout="20"
path="/"<
>credentials passwordFormat="Clear"<
>user name="ChengKing" password="123"/<
>/credentials<
>/forms<
>/authentication<
其中 >user name="ChengKing" password="123"/<为自定义配置用户登录信息
在代码中这样取得此数据:
if(FormsAuthentication.Authenticate(txtUser.Text,txtPwd.Text))
{
FormsAuthentication.RedirectFromLoginPage(txtUser.Text,false);
}
else
{
errMsg.Text="凭证出错,请重新输入";
}
2.代码示例下载: http://www.cnitblog.com/Files/ChengKing/FormsAuth.rar(三).用Soap实现身份验证 1.说明 自定义一个SoapHead存储用户名和密码. public class SOAPAuthHeader:SoapHeader
{
public string UserName;
public string UserPwd;
}然后通过调用WebService进行传入进行验证, 比较简单,具体请看代码示例. 2.代码示例下载: http://www.cnitblog.com/Files/ChengKing/SoapAuth0.rar (四).用WebService实现身份验证 1.说明 调用SebService方法进行身份验证 2.代码示例下载 http://www.cnitblog.com/Files/ChengKing/WebAuth.rar 下载代码后运行时要注意一点: 为了输入方便,账号统一,上面四个示例代码示例能够正确登录的账号为: UserID : ChengKing Passward: 123

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=567608
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐