Exemplo n.º 1
0
 public HttpResponseMessage Post(LogOnModel user)
 {
     try
     {
         Impersonate.ImpersonateUser(ConfigurationManager.AppSettings["Domain"].ToString(), user.UserName, user.Password);
         if (this.ValidateUser(user))
         {
             FormsAuthentication.SetAuthCookie(user.UserName, true);
             return Request.CreateResponse(HttpStatusCode.OK, true);
         }
         return Request.CreateResponse(HttpStatusCode.OK, false);
     }
     catch (DirectoryServicesCOMException dse)
     {
         HttpError error = new HttpError(dse.Message.Replace("\n", " ").Replace("\r", " ").Replace("\t", " "));
         return Request.CreateResponse(HttpStatusCode.Unauthorized, error);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         Impersonate.UndoImpersonation();
     }
 }
Exemplo n.º 2
0
 public HttpResponseMessage Post(LogOnModel model)
 {
     try
     {
         if (this.ValidateUser(model))
         {
             FormsAuthentication.SetAuthCookie(model.UserName,true);
             return Request.CreateResponse(HttpStatusCode.OK, true);
         }
         return Request.CreateResponse(HttpStatusCode.OK, false);
     }
     catch (DirectoryServicesCOMException dse)
     {
         HttpError error = new HttpError(dse.Message.Replace("\n", " ").Replace("\r", " ").Replace("\t", " "));
         return Request.CreateResponse(HttpStatusCode.Unauthorized, error);
     }
     catch (Exception ex)
     {
         HttpError error = new HttpError(ex.Message.Replace("\n", " ").Replace("\r", " ").Replace("\t", " "));
         EventLog log = new EventLog();
         log.Source = "Jaguar_Mobile";
         log.WriteEntry(ex.Message);
         return Request.CreateResponse(HttpStatusCode.InternalServerError, error);
     }
 }
Exemplo n.º 3
0
 private bool ValidateUser(LogOnModel model)
 {
     bool valid = false;
     using (Entities context = new Entities())
     {
         valid = context.P_Personas.Count(p => p.usuario == model.UserName) > 0;
         if (valid)
         {
             DirectoryEntry entry = new DirectoryEntry("LDAP://" + "earth.ac.cr", model.UserName, model.Password);
             //TODO: uncomment this line in server.
             object nativeObject = entry.NativeObject;
         }
     }
     return valid;
 }
Exemplo n.º 4
0
        private bool ValidateUser(LogOnModel model)
        {
            bool valid = false;

            using (SGA_DesarrolloEntities context = new SGA_DesarrolloEntities())
            {
                valid = context.P_Personas.Count(p => p.login_red == model.UserName) > 0;
                if (valid)
                {
                    DirectoryEntry entry = new DirectoryEntry("LDAP://" + ConfigurationManager.AppSettings["Domain"].ToString(), model.UserName, model.Password);
                    //TODO: uncomment this line in server.
                    object nativeObject = entry.NativeObject;
                }
            }
            return valid;
        }