As Jon Dowell wrote, assuming you are using "Integrated" security, you
should create a User in the Domain specifically for this service. Create
the same username/password combination as an SQL Server login and give it
access to the appropriate database objects. Double check that the correct
mapping exists in the SQL Security manager from the domain login to the SQL
login, and create it if necessary. Then, be sure that the service is running
with this domain user/password combination (can be set by CreateService() or
by Control Panel - Services Applet). Don't specify any username/password in
the connection string.
This should solve the security issue.
Now for a question of my own (sorry if this is a breach of netiquette).
I've tried to do exactly the same thing -- create an NT service in VC++
using ADO to talk to an SQL Server. I'm not getting the same problem --
instead I'm getting a different error where the service can't open the first
connection. It's not in ODBC, but in ADO itself (it appears). What happens
is I get an exception with the following error message:
The system could not find the environment option that was set.
This is error #203 in winerror.h. The exact same software, with no changes
at all, runs fine as an interactive task (from the command line in a "debug"
mode). It only fails when executed as a service.
To eliminate ODBC as the culprit, I turned on ODBC tracing. No entries were
made before the error occurs. I also tried using the OLE DB data provider
(SQLOLEDB) instead. The exact same things occured. Do you have any ideas
for me?
Eric Raskin
P.S. I've been working this problem under the thread named "ADO in NT
Service fails!". Feel free to post there or e-mail me with any suggestions
at all. It's been three tough days on this problem so far!
>> Microsoft OLE DB Provider for ODBC Drivers error '80004005'
>> [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed- User: _
>Reason: Not defined as a
>> valid user of a trusted SQL Server connection.
>I tried using the following to no avail...
>> rs.Open sql,
>"DSN=keyindicators;uid=sa;password=12345;database=keyindicators"
>Any suggestions?
>>If you configure the service to run under an NT account with permissions
on
>>the SQL Server (and the server is using integrated or mixed security),
then
>>you are done. Don't specify the userID/password, NT will deal with it.
>>-Jon