siteidentity.cs

来自「基于角色的用户验证. 这个程序重点写了四个pages以实现这些功能:增加用户」· CS 代码 · 共 71 行

CS
71
字号
using System;
using System.Data;
using System.Data.SqlClient;

namespace RolesBasedAthentication
{
	public class SiteIdentity: System.Security.Principal.IIdentity
	{
		private int userID;
		private string fullName;
		private string email;
		private string password;
		
		public SiteIdentity( string email )
		{
			User user = new User(email);

			this.userID = user.UserID;
			this.fullName = user.FullName;
			this.email = user.Email;
			this.password = user.Password;
		}

		public SiteIdentity( int userID )
		{
			User user = new User(userID);

			this.userID = user.UserID;
			this.fullName = user.FullName;
			this.email = user.Email;
			this.password = user.Password;
		}

		// Properties
		public string AuthenticationType
		{
			get { return "Custom Authentication"; }
		}

		public bool IsAuthenticated
		{
			get 
			{
				// assumption: all instances of a SiteIdentity have already
				// been authenticated.
				return true;
			}
		}

		public int UserID
		{
			get { return userID; }
		}

		public string Name
		{
			get { return fullName; }
		}

		public string Email
		{
			get { return email; }
		}				

		public string Password
		{
			get { return password; }
		}
	}
}

⌨️ 快捷键说明

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