【ChengKing(ZhengJian)】

【ChengKing(ZhengJian)】

博客园 首页 联系 订阅 管理

(一).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  

               

 

  

posted on 2006-01-15 22:45  【ZhengJian】  阅读(977)  评论(0编辑  收藏  举报