示例#1
0
        /// <summary>
        /// load claims from dc
        /// </summary>
        /// <param name="principal">Distinguished Name of principal</param>
        /// <param name="principalClass">class type of principal</param>
        /// <param name="dc">Domain Controller name or address</param>
        /// <param name="domain">domain DNS name</param>
        /// <param name="user">admin user name</param>
        /// <param name="password">admin user password</param>
        public static void LoadClaims(string principal, ClaimsPrincipalClass principalClass, string dc, string domain, string user, string password)
        {
            ClaimsLoader cLoader = new ClaimsLoader(dc, domain, user, password);

            List <CLAIMS_ARRAY> adClaims = cLoader.GetClaimsForPrincipalWithoutEncode(principal, ClaimsPrincipalClass.User, ClaimsSource.AD | ClaimsSource.Certificate);

            sourceClaims = adClaims.ToArray();
        }
示例#2
0
        public IActionResult Index()
        {
            //Set the role for the user; This is accessed by the layout page to display role to the user.
            if (ClaimsLoader.IsInGroup(User, _config.GetValue <string>("Admin")))
            {
                ClaimsLoader.Role = "Administrator"; //THIS IS USED BY LAYOUT TO HANDLE WHICH LINKS APPEAR TO THE USER.
            }
            else if (ClaimsLoader.IsInGroup(User, _config.GetValue <string>("Modify")))
            {
                ClaimsLoader.Role = "Modify";
            }
            else
            {
                ClaimsLoader.Role = "";
            }

            List <Circuit>      circuits     = _context.Circuit.ToList();
            List <DiscoCircuit> discoCircuit = _context.DiscoCircuits.ToList();
            List <Software>     soft         = _context.Software.ToList();
            List <Circuit>      last30       = new List <Circuit>();
            List <DiscoCircuit> last30Disco  = new List <DiscoCircuit>();
            List <Software>     last30Soft   = new List <Software>();

            foreach (var item in circuits)
            {
                if ((item.Date - DateTime.UtcNow).TotalDays > -30)
                {
                    last30.Add(item);
                }
            }
            foreach (var item in discoCircuit)
            {
                if ((item.Date - DateTime.UtcNow).TotalDays > -30)
                {
                    last30Disco.Add(item);
                }
            }
            foreach (var item in soft)
            {
                if ((item.added - DateTime.UtcNow).TotalDays > -30)
                {
                    last30Soft.Add(item);
                }
            }
            DashboardView newdash = new DashboardView
            {
                RecentCircuit = last30,
                RecentDisco   = last30Disco,
                RecentSoft    = last30Soft
            };


            return(View(newdash));
        }