0
我正在使用ManagementClass在遠程計算機上執行EXE。嘗試在遠程計算機上執行EXE EXE登錄失敗
var serverPath = new ManagementPath
{
Server = "SERVERNAME",
NamespacePath = "\\ROOT\\CIMV2",
ClassName = "Win32_Process"
};
var connection = new ConnectionOptions
{
Username = _Domain + @"\" + _UserName,
Password = _Pass,
Impersonation = ImpersonationLevel.Impersonate,
Authentication = AuthenticationLevel.Packet,
EnablePrivileges = true,
Timeout = new TimeSpan(0, 0, 15)
};
var ms = new ManagementScope(serverPath, connection);
var mprocess = new ManagementClass(ms, new ManagementPath("Win32_Process"), new ObjectGetOptions());
var inParams = mprocess.GetMethodParameters("Create");
inParams["CommandLine"] = @"F:\Utils\Directory\program.exe";
inParams["CurrentDirectory"] = @"F:\Utils\Directory\";
mprocess.InvokeMethod("Create", inParams, null);
我是從我的應用程序收到以下錯誤:
System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at KPlusSynchronizer.Tyche.StoreIntoDatabase(String tycheConnection, String sp, XDocument xml, Boolean logXml, String path, String user)
at KPlusSynchronizer.Synchronizer.Synchronize(String tycheTable, String tycheSp, String kplusSp, String path, String user)
當我手動登錄使用相同的用戶名和密碼在服務器上爲ConnectionOptions和手動啓動該exe它工作正常。
我也嘗試在嘗試連接之前使用ImpersonateUser(使得我管理員,與用戶名和密碼相同)。
任何人都可以看到我失蹤了嗎?
您是否處理互動?在哪個Os上啓動遠程進程? Dis解決方案不適用於交互式流程(與UI交互的流程) – 2015-02-24 10:46:47
@ManuelAmstutz操作系統是「Microsoft Windows Server 2012 Datacenter」。這個過程不是交互式的,但它使用數據庫中的集成安全性來調用數據庫...我看到完整的錯誤消息抱怨了一些Sql。將更新全錯誤的問題 – MrProgram 2015-02-24 10:50:02