public ActionResult Index(FormCollection form, LdapConfiguration model)
        {
            var email = form["email"];
            var password = form["password"];

            if (ModelState.IsValid && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {
                var objLdap = new LdapManager(model);

                if (objLdap.Authenticate(email, password))
                {
                    TempData["Message"] = "Connection sucessful establish.";
                }
                else
                {
                    ModelState.AddModelError("",@"Test failed");
                }
            }
            else
            {
                ModelState.AddModelError("",@"Please input username password");
            }

            return View("Index");
        }
 public ActionResult Index(LdapConfiguration model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             ConfigurationRepository.LdapConfiguration = model;
             TempData["Message"] = Resources.LdapConfigurationController.UpdateSuccessful;
             return RedirectToAction("Index");
         }
         catch (ValidationException ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
         catch
         {
             ModelState.AddModelError("",Resources.LdapConfigurationController.ErrorUpdatingConfiguration);
         }
     }
     return View("Index", model);
 }
Exemplo n.º 3
0
 public LdapManager(LdapConfiguration ldap)
 {
     _ldap = ldap;
 }