I'm trying to connect to SQL Server using Windows authentication. Th开发者_StackOverflowe code works fine when I run it as a plain executable but when I put it in a Windows service I get the error: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'
I tried passing the username and password via the connection string but that doesn't help.
Any ideas?
If you're running as a servie, you'll need to change the logon identity for the Windows Service.
- Start > Run > Services.msc
- Right-click on the service in "Services"
- Choose the "Log On" tab
- Enter the account name and password for the domain user into the "This account", "Password" and "Confirm password" boxes
- Click "OK"
- Restart the service
When configuring a process to connect to Sql Server via Integrated Authentication you don't/can't specify the username/password combination in the connection string.
Configure the service to run as an account with access to SQL Server. Service Properties - Log On - This account
精彩评论