Authentication/AuthBase.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;


namespace ComLib.Authentication
{
    /// <summary>
    /// This is the base class from which all authentication implementations 
    /// must derive from (currently inherited by <see cref="ComLib.Authentication.AuthWeb"/> and
    /// <see cref="ComLib.Authentication.AuthWin"/>).
    /// </summary>
    public abstract class AuthBase
    {
        /// <summary>
        /// Defines the role name for administrators.
        /// </summary>
        protected string _adminRoleName = "Administrators";


        /// <summary>
        /// The name of the current user.
        /// </summary>
        public abstract string UserName { get; }


        /// <summary>
        /// Provides just the username if the username contains
        /// the domain.
        /// e.g. returns "john" if username is "mydomain\john"
        /// </summary>
        public abstract string UserShortName { get; }


        /// <summary>
        /// Get the current user.
        /// </summary>
        public abstract IPrincipal User { get; }


        /// <summary>
        /// The user id.
        /// </summary>
        public int UserId
        {
            get
            {
                var user = User;
                if (user != null && user is UserPrincipal)
                    return ((UserPrincipal)user).UserId;

                return -1;
            }
        }


        /// <summary>
        /// Determine if the current user is authenticated.
后面还有 62 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。