global.asax

来自「本文件为ASP开发的在线播放系统,挺不错的,创建数据需按照说明进行创建,祝你成功」· ASAX 代码 · 共 57 行

ASAX
57
字号
<%@ Import Namespace="System.Security.Principal" %>

<script language="C#" runat="server">

public class MyIdentity  : IIdentity {
   private string mName;
   public MyIdentity(string InName){
	mName=InName;
   }	
   public  bool IsAuthenticated  {
      get {
         return true;
      }
   }
   public  string Name  {
      get {
         return mName;
      }
   }	
   public  string AuthenticationType  {
      get {
         return "MyType";
      }
   }	
}

public class MyPrincipal : IPrincipal {
	private MyIdentity mIdentity;	
	public  MyPrincipal (WindowsIdentity id){
	   mIdentity = new MyIdentity(id.Name);
	}

	public  IIdentity Identity {
	   get {
	      return mIdentity;
	   }
	}
     	
	public bool IsInRole(string role){
	   if (mIdentity.Name=="CHERRY\\Miles")
	      return true;
	   else
	      return false;   
	}
}

public void WindowsAuthentication_OnAuthenticate(Object Source, WindowsAuthenticationEventArgs  e) {
            
  e.User = new  MyPrincipal(e.Identity);
}




</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?