当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·远程数据库复制    »显示摘要«
    摘要: 远程数据库均为sql server2000,如何将数据库的所有表及记录自动复制至另一个数据库,要求自动进行.原采用数据导出,以作业的方式定时进行.但数据传输不安全.不知有何高招. ......
    摘要: 如何access数据库中检索符合条件的记录,让后将他们用dbgrid空间显示,并统计个数? 我刚接触vb,请各位大虾多多指教! ......


forms 验证

目录如下:   Main   ____Book/*.*  
                                  |___Ticket/*.*  
                                  |___Help/*.*  
                                  |..........(全部是目录)  
                                  |___index.aspx  
                                  |___web.config  
   
  我希望用户必须从登陆页登陆,验证合法后,才能访问Main目录下,所有目录中的文件。请大家多多帮助!

NO.1   作者: neodotnet

如果用户量大的话就用cookie

NO.2   作者: stpangpang

login.aspx.cs  
   
  //从数据库读取用户的权限  
  string   role=reader.GetInt32(0).ToString();  
  //产生   Ticket  
  FormsAuthenticationTicket   userTicket=new   FormsAuthenticationTicket(1,uid,  
  DateTime.Now,DateTime.Now.AddMinutes(30),true,role,"login");  
   
  //加密票据  
  string   hashUserTicket=FormsAuthentication.Encrypt(userTicket);  
  //产生新的Cookie  
  HttpCookie   userCookie=new   HttpCookie("login",hashUserTicket);  
  Response.Cookies.Add(userCookie);  
   
   
  //返回用户原来返回的页面  
  Context.Response.Redirect(Context.Request["ReturnUrl"],true);  
   
  global.asax.cs  
   
  protected   void   Application_AuthenticateRequest(Object   sender,   EventArgs   e)  
  {  
                  HttpApplication   app=(HttpApplication)sender;  
  HttpContext   ctx=app.Context;  
  //如果验证成功  
  if(ctx.Request.IsAuthenticated==true)  
  {    
          FormsIdentity   typeID=(FormsIdentity)ctx.User.Identity;  
          FormsAuthenticationTicket   ticket=typeID.Ticket;  
          string   []role=ticket.UserData.Split(,);  
          ctx.User=new   GenericPrincipal(typeID,role);  
  }  
  }  
   
  文件夹底下的web.config的培植  
  <authorization>  
  <allow   roles="1"/>  
  <deny   users="*"/>  
  </authorization>  
   
  我的权限   role   有三种,   为这三个权限建立三个   文件夹  
   
  要   导入的命名空间  
   
  using   System.Web.Security;  
  using   System.Security.Principal;  
 

NO.3   作者: saucer

>>>>我在程序验证用户合法后,加了一句:ForsAuthentication.SetAuthCookie("",False),  
  就可以了,为什么?  
   
  that   is   how   it   works  
   
   
  >>>>这样做的验证,是不是包括了Main下的所有目录+文件,  
   
  suppose   so  
   
  >>>如果,文件不想被验证呢?  
   
  add   a   location   element   to   your   web.config:  
   
   
  <configuration>  
   
  <system.web>  
        <authentication   mode="Forms">  
                  <forms   name=".theDefault"    
                                loginUrl="index.aspx"    
                                path="/"    
                                protection="All"    
                                timeout="15"   >  
                  </forms>  
        </authentication>  
      <authorization>  
              <deny   users="?"   />  
      </authorization>  
  </system.web>  
   
  <location   path="SomeOtherPage.aspx">  
      <system.web>  
              <authorization>  
                      <allow   users="*"   />  
              </authorization>  
      </system.web>  
  </location>  
   
  </configuration>  
   
   
   
 


    摘要: 怎么实现? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE