private void KickOffCimAsync(Computer computer, Credential credential, string commandline, CimSessionOptions options) { var optionsBuilder = new DbContextOptionsBuilder <ACEWebServiceDbContext>(); optionsBuilder.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Database=ACEWebService;Trusted_Connection=True;MultipleActiveResultSets=true"); using (ACEWebServiceDbContext context = new ACEWebServiceDbContext(optionsBuilder.Options)) { // Convert stored password to a secure string SecureString securePwd = new SecureString(); foreach (char c in _cryptoService.Decrypt(credential.Password)) { securePwd.AppendChar(c); } CimCredential cimCreds = null; if (credential.UserName.Contains('\\')) { // Create a CimCredential object cimCreds = new CimCredential(PasswordAuthenticationMechanism.Kerberos, credential.UserName.Split('\\')[0], credential.UserName.Split('\\')[1], securePwd); } else { // Create a CimCredential object cimCreds = new CimCredential(PasswordAuthenticationMechanism.Default, null, credential.UserName, securePwd); } // Create a CimSession with the remote system options.AddDestinationCredentials(cimCreds); CimSession session = CimSession.Create(computer.ComputerName, options); // Create a CimMethodParametersCollection to pass to method invocation CimMethodParametersCollection collection = new CimMethodParametersCollection(); collection.Add(CimMethodParameter.Create("CommandLine", commandline, CimFlags.None)); CimMethodResult result = session.InvokeMethod("root/cimv2", "Win32_Process", "Create", collection); if (result.ReturnValue.ToString() == "0") { } else { } session.Dispose(); } }
public SweepController(ISweepExecutionService sweepExecutionService, ACEWebServiceDbContext context) { _sweepExecutionService = sweepExecutionService; _context = context; }
public DownloadService(ACEWebServiceDbContext context, ICryptographyService cryptoService, IOptions <AppSettings> settings) { _context = context; _cryptoService = cryptoService; _settings = settings.Value; }
public UserController(ACEWebServiceDbContext context) { _context = context; }
public DownloadController(ACEWebServiceDbContext context, IHostingEnvironment hostingEnv, IDownloadService downloadService) { _context = context; _hostingEnv = hostingEnv; _downloadService = downloadService; }
public ApiKeyHandler(ACEWebServiceDbContext context) { _context = context; }
public DiscoveryActiveDirectoryService(ACEWebServiceDbContext context, ICryptographyService cryptoService) { _context = context; _cryptoService = cryptoService; }
public ScriptController(ACEWebServiceDbContext context, IHostingEnvironment hostingEnv) { _context = context; _hostingEnv = hostingEnv; }
public CredentialController(ACEWebServiceDbContext context, ICryptographyService cryptoService) { _context = context; _cryptoService = cryptoService; }
public ScheduleController(ACEWebServiceDbContext context, ISchedulingService schedulingService) { _context = context; _schedulingService = schedulingService; }
public IsAdminHandler(ACEWebServiceDbContext context) { _context = context; }
public SweepExecutionService(ACEWebServiceDbContext context, ICryptographyService cryptoService) { _context = context; _cryptoService = cryptoService; }
public ScanController(ACEWebServiceDbContext context) { _context = context; }