C#.NET应用程序无法在终端服务中访问SQL Server



我写了一个访问MS SQL Server的C#应用程序。我对应用程序的开发没有任何问题。我现在在部署阶段,一个奇怪的问题已经出现。该应用程序将通过终端服务向最终用户提供。由于某些原因,如果标准用户执行了应用程序,则该应用程序无法访问数据库,仅当用户是域管理安全组的成员时,它才能访问它。如果我为用户服务SQL Management Studio或使用ODBC DSN连接到数据库,则可以访问数据库。它似乎与.NET应用程序有关。我通过Citrix为应用程序提供服务,但也有一个2倍的环境,并且在两者中都有相同的问题。终端服务和.NET都必须是某种东西。

欢迎任何建议或人们在类似问题上的经验。

编辑:

这是我在用户不是域管理组成员

成员时得到的例外

system.data.sqlclient.sqlexception(0x80131904):在建立与SQL Server的连接时发生了与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是正确的,并且配置了SQL Server以允许远程连接。(提供商:SQL网络接口,错误:26-指定的服务器/实例的错误定位) at System.Data.SQLClient.SQLineTeral Connection.OnError(Sqlexception异常,布尔旋转折断,动作1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) 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重试,dbConnectionOptions userOptions,dbConnectioninternal& amp;连接) 在system.data.data.providerbase.dbconnectionfactory.trygetConnection(dbConnection Conconnection,TaskCompletionsource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1重试,dbConnectionOptions userOptions) at System.data.providerbase.dbConnectionClosed.Tryopenconnection(dbConnection outerConnection,dbConnection -factractory connectionFactory,taskCompletionsource 1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1重试) 在system.data.sqlclient.sqlconnection.troopen(taskCompletionsource`1重试) 在system.data.sqlclient.sqlconnection.open() 在camlabs.utilityclasses.dbconn.isconnected()上clientConnection Id:000000-0000-0000-0000-0000-000000000000

当他们是该组的成员时,它没有错误。

rhope问题在您的连接字符串中。可能是您正在连接字符串中使用集成安全选项。如果是 - 请将您的连接字符串更改为使用SQL Server授权的字符串。不要忘记将用户和用户映射添加到相应的数据库中。https://www.connectionstrings.com/

最新更新