private object IsKenosRunning(AutenticacionModel autenticacion, string nombreInstancia) { try { ConnectionOptions options = new ConnectionOptions(); options.Impersonation = System.Management.ImpersonationLevel.Impersonate; options.Authentication = AuthenticationLevel.Packet; options.Username = string.Format("{0}\\{1}", autenticacion.Dominio, autenticacion.Usuario); options.Password = autenticacion.Password; ManagementPath mp = new ManagementPath(); mp.NamespacePath = @"\root\cimv2"; mp.Server = nombreInstancia; ManagementScope scope = new ManagementScope(mp, options); scope.Connect(); string query = "SELECT * FROM Win32_Process WHERE Name='Kenos.Win.exe'"; var searcher = new ManagementObjectSearcher(query); searcher.Scope = scope; return(searcher.Get().Count > 0); } catch (Exception ex) { return(ex.Message); } }
private List <string> GetArchivos(AutenticacionModel autenticacion, string path) { List <string> list = new List <string>(); using (SimpleImpersonation.Impersonation.LogonUser(autenticacion.Dominio, autenticacion.Usuario, autenticacion.Password, SimpleImpersonation.LogonType.NetworkCleartext)) { System.IO.DirectoryInfo dirInfo = new DirectoryInfo(path); foreach (System.IO.FileInfo file in dirInfo.GetFiles()) { list.Add(file.Name); } } return(list); }
public ActionResult Create([Bind(Include = "usuario, pass")] AutenticacionModel auth) { try { UsuarioADM usuarios = new UsuarioADM(); Usuario usuario = usuarios.validarUsuario(auth.usuario, auth.pass); System.Web.HttpContext.Current.Session["sessionString"] = new JavaScriptSerializer().Serialize(usuario); System.Web.HttpContext.Current.Session["Usuario"] = usuario; return(RedirectToAction("Index", "Home")); } catch (Exception e) { ViewBag.noValido = e.Message; return(View("Index")); } }