0

I created a windows service for monitoring to send data (OS info, proc, ram etc) to my SQL Server database and it works fine on my computer. I already installed the service in another machine that has SQL Server and it can connect to mydatabase successfully but when the service runs it appear those error in service log.

This is my connection string

CONNECTION_STRING = "Server=*******\\SQLEXPRESS;Database=Parc_informatique; User Id=tsi;password=******;";

Also the service run as local user

2020-07-22 15:09:34.7392 - DEBUG: Starting service 2020-07-22 15:09:34.7392 - DEBUG: Callback started 2020-07-22 15:09:34.7392 - DEBUG: Starting sending Data 2020-07-22 15:09:35.1712 - ERROR: System.Data.SqlClient.SqlException (0x80131904): Échec de l'ouverture de session de l'utilisateur 'AUTORITE NT\ANONYMOUS LOGON'. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) 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, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.Open() at SignalRbus.InfoManager.SendData() in C:\Users\Rayen\source\repos\project\SignalRbus\SystemInfo.cs:line 197 at DetailService.Service1.serviceTimer_callback(Object state) in C:\Users\Rayen\source\repos\project\DetailService\Service1.cs:line 45 ClientConnectionId:a19ffe41-1f72-4e44-a883-f4eed400e93e Error Number:18456,State:1,Class:14 ClientConnectionId :00000000-0000-0000-0000-000000000000 Error Number :-1,State :0,Class :20

4
  • You should either run the service as a user who has access to your SQL database and use a connection string with a trusted connection. Or you should update your connection string with a username and password that has access to your database. Commented Aug 6, 2020 at 17:37
  • Does this answer your question? SQL Server returns error "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'." in Windows application Commented Aug 6, 2020 at 17:39
  • I have a connection string with username , password and ,I can connect to my database through SQl server management in the other machine but the service doesn't work and that what I find in log of the windows service Commented Aug 7, 2020 at 0:47
  • CONNECTION_STRING = "Server=*\SQLEXPRESS;Database=Parc_informatique; User Id=tsi;password=;Integrated Security=False;" Commented Aug 3, 2021 at 17:06

1 Answer 1

0

I solved it by adding Integrated Security=False to the connection string like this

CONNECTION_STRING = "Server=*\SQLEXPRESS;Database=Parc_informatique; User Id=tsi;password=;Integrated Security=False;"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.