コード例 #1
0
ファイル: CarrielPrincipal.cs プロジェクト: alexan1/marketweb
		public CarrielPrincipal(CarrielIdentity Identity, string[] Roles, string[] RoleLevels)
		{
			_Identity = Identity;
			_Roles = Roles;
			_RoleLevels = RoleLevels;
			Array.Sort(_Roles, _RoleLevels);
		}
コード例 #2
0
		private void context_AuthenticateRequest(object sender, EventArgs e)
		{
			//HttpApplication app = (HttpApplication) sender;
			IPrincipal user = HttpContext.Current.User;

			if (user != null)
			{
				if (user.Identity.IsAuthenticated)
				{
					if (user.Identity.AuthenticationType == "Forms")
					{
//						try
//						{
							//We need the forms Identity so that we can get the userdata from the Forms Cookie
							FormsIdentity formID = (FormsIdentity) user.Identity;

							//Split the userdata into three strings, MemberID, Role Memberships, And Access Levels for those Roles
							string[] userInfo = formID.Ticket.UserData.Split(';');

							//Create the new identity based on the form identity, including MemberID
							CarrielIdentity iden = new CarrielIdentity(formID, Convert.ToInt32(userInfo[0]));

							//Create a new Principal Object With Roles, and Role Levels
							HttpContext.Current.User = new CarrielPrincipal(iden, userInfo[1].Split(','), userInfo[2].Split(','));

						
//						}
//						catch (Exception)
//						{
//							FormsAuthentication.SignOut();
//							
//						}
					}
				}
			}
		}