Ejemplo n.º 1
0
        protected void Session_Start(object sender, EventArgs e)
        {
            string userName = User.Identity.Name;

            userName = userName.Substring(userName.LastIndexOf(@"\") + 1);
            PrincipalContext yourDomain    = new PrincipalContext(ContextType.Domain);
            UserPrincipal    userPrincipal = UserPrincipal.FindByIdentity(yourDomain, userName);

            if (userPrincipal != null)
            {
                Application.Main.Interfaces.SunucuEnvanter.

                ISunucuEnvanterKullaniciAppService kullaniciAppService = RDependencyFactory.Resolve <ISunucuEnvanterKullaniciAppService>();
                AvKullanici user = kullaniciAppService.GetUserByUserName(userName);
                if (user != null)
                {//user is admin
                    RSession.UserInfo = new UserInfo()
                    {
                        UserName = userName, UserId = user.Id, EMail = userPrincipal.EmailAddress, NameSurname = userPrincipal.DisplayName
                    };
                    SetGroupInfos(userName);
                    Session["IsAdmin"] = user.IsAdmin;
                    Session["EMail"]   = user.KullaniciEMail;
                }
                else
                {//user is not admin
                    RSession.UserInfo = new UserInfo()
                    {
                        UserName = userName, UserId = 9999, EMail = userPrincipal.EmailAddress, NameSurname = userPrincipal.DisplayName
                    };
                    SetGroupInfos(userName);
                    Session["IsAdmin"] = false;
                    Session["EMail"]   = userPrincipal.EmailAddress;
                }
            }
            else
            {
                Response.Redirect("/Home/AccessDenied");
            }
        }
Ejemplo n.º 2
0
 protected override Rota2.DataCore.REfUnitOfWork ResolveUoW()
 {
     return((REfUnitOfWork)RDependencyFactory.Resolve <IQueryableUnitOfWork>("SunucuEnvanterDbContext"));
 }