Exemple #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //temp until windows auth enable
            AmecUser user = new AmecUser();

            user.NtId      = tbUserName.Text.Trim();
            user.Name      = user.NtId;
            user.GivenName = user.NtId;
            user.Email     = "*****@*****.**";
            lvDb.UserInit(user);
            Session[Constants.UserSession] = user;
            Response.Redirect("~/Leave/LeaveSubmit.aspx");
        }
        public static AmecUser UserInit()
        {
            LeaveDataAccess lvDb     = new LeaveDataAccess();
            AmecUser        amecUser = new AmecUser();
            string          userName = HttpContext.Current.User.Identity.Name;
            string          ntid     = userName.Split('\\')[1];

            amecUser.NtId = ntid;

            using (PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "GICNT")) {
                using (UserPrincipal oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, userName))
                {
                    amecUser.Email     = oUserPrincipal.EmailAddress;
                    amecUser.GivenName = oUserPrincipal.GivenName;
                    amecUser.Name      = oUserPrincipal.ToString();
                }
            }
            lvDb.UserInit(amecUser);
            return(amecUser);
        }