コード例 #1
0
ファイル: UserAuthentication.cs プロジェクト: qiji/AutoCourse
        public static void Authentication(this HttpContextBase httpcontext, string username, AutoCourse.Models.ManageUser manageuser)
        {
            ClaimsIdentity _identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie);
            if (manageuser == null)
            {
                _identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, username));
                _identity.AddClaim(new Claim(ClaimTypes.GroupSid, "0"));
            }
            else
            {
                _identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, manageuser.UserName));
                _identity.AddClaim(new Claim(ClaimTypes.GroupSid, manageuser.SchoolID.ToString()));
            }
            _identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity"));

            httpcontext.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            httpcontext.GetOwinContext().Authentication.SignIn(new AuthenticationProperties() { IsPersistent = true }, _identity);
        }
コード例 #2
0
 public void SelectAutoCourse()
 {
     AutoCourse.Click();
 }