private void SetConnectionService() { _connectionService = new ConnectionService(); _options = new ConnectionOptions(); _options.Impersonation = _connectionService.SetImpersonationLevel(); _scope = _connectionService.GetCIMConnection(_options); _scope.Connect(); }
private void SetConnectionService(string computerName, string userName, string password) { _connectionService = new ConnectionService(); _options = new ConnectionOptions(); _options.Impersonation = _connectionService.SetImpersonationLevel(); SecureString securepassword = new SecureString(); foreach (char c in password) { securepassword.AppendChar(c); } _options.SecurePassword = securepassword; _options.Username = userName; // _options.Authority = "NTLMDOMAIN:" + "KOTEG"; _scope = _connectionService.GetCIMConnection(computerName, _options); _scope.Connect(); }