Exemplo n.º 1
0
        public async Task <IActionResult> LDAP(LDAPViewModel model, string returnUrl = null)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByNameAsync(model.UserName);

                if (user != null)
                {
                    var cn = new LdapConnection();
                    cn.Connect("pg.com", 389);
                    try
                    {
                        var usr = "******" + model.UserName;
                        var psw = model.Password;
                        cn.Bind(usr, psw);

                        var result = await _signInManager.PasswordSignInAsync(model.UserName, defaultAssignedPassword, false, lockoutOnFailure : false);

                        var user1 = await _userManager.FindByEmailAsync(model.UserName + "@pg.com");

                        CheckIfLate(user1);

                        return(RedirectToAction("ShowLandingPage"));
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError(string.Empty, "Incercare de autentificare invalida!");
                        return(View(model));
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Incercare de autentificare invalida!");

                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
Exemplo n.º 2
0
 public LDAPPage()
 {
     InitializeComponent();
     Model = new LDAPViewModel(this);
     ApplicationContext.LdapExpandedIdList = new List <string>();
 }