示例#1
0
      public void HasNameAndId()
      {
         TadmapIdentity identity = new TadmapIdentity("Name", "Display Name", Guid.Empty, string.Empty);

         Assert.AreEqual("Name", identity.Name);
         Assert.AreEqual("Display Name", identity.DisplayName);
         Assert.AreEqual(Guid.Empty, identity.Id);
      }
示例#2
0
      protected void Application_AuthenticateRequest(Object sender, EventArgs e)
      {
         HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

         if (authCookie != null)
         {
            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            CookieUserData userData = CookieUserData.Parse(authTicket.UserData);
            var identity = new TadmapIdentity(authTicket.Name, userData.DisplayName, userData.Id, "Forms");

            Context.User = new GenericPrincipal(identity, userData.Roles);
         }
      }