Re: Connecting to SQL from a Windows Service



When you are connected to SQL Server as "Windows (XP Pro) as an Admin" and you run the query:
USE master
GO
SELECT * FROM syslogins
WHERE name = 'NT AUTHORITY\SYSTEM'
GO
Does it return a row for that login?
And most of the values should look like your login: denylogin = 0, hasaccess = 1, dbname is probably master or your desired database.
And after login, does the 'NT AUTHORITY\SYSTEM' has access to the correct database as a user?

Also, You can try turning on login auditing in SQL Server and then check the SQL Server error log. Maybe you will see more info about the login attempt.
--
Rick Byham (MSFT)
This posting is provided "AS IS" with no warranties, and confers no rights.

"RML" <RML@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:E21B3350-9477-4DCE-8E64-3690FFB2BAD3@xxxxxxxxxxxxxxxx
Hi all, I have written a Windows Service that attempts to connect to an SQL
2005 Express Database when started. The login always fails. The login uses
Windows Authentification (NT AUTHORITY/SYSTEM user).

I also tried connecting using the "sa" SQL Server login, and it still fails.

If I log into Windows (XP Pro) as an Admin, and manually start the service,
it connect Ok.

I thought that maybe the SQL Server service "MSSQL$SQLEXPRESS" may not be
started yet when my service attempts to connect, but the Evetn Log show it is
started before my service starts. Also, my service is Dependant on
MSSQL$SQLEXPRESS.

Can anyone point me in the right direction.

RML

.



Relevant Pages

  • Re: login 101..
    ... On Windows 2003, SQL Server 2005 can enforce the Windows password complexity ... Windows authentication - SQL Server uses a special protocol to ask ... user is in the list of allowed logins, ...
    (microsoft.public.sqlserver.security)
  • RE: How to create a trusted connection
    ... You need to grant access for the Windows login by referring to the books ... is set to use Windows authentication to be able to do trusted connection. ... There are two modes of authentication in SQL Server: ...
    (microsoft.public.sqlserver.security)
  • Re: Windows NT user or group not found.
    ... out what SQL Server thinks the login name is vs. what Windows thinks the ... When the SQL Server collation and the Windows collation are different, ... The following example uses the Param2 parameter to get the SID from Windows ...
    (microsoft.public.sqlserver.connect)
  • RE: How to create a trusted connection
    ... What do you mean by "creating a Windows login"? ... To login SQL Server 2000 using trusted connection, grant the Windows ... Group" in SQL Server Books Online to get the concept, ...
    (microsoft.public.sqlserver.security)
  • Re: Connecting to SQL from a Windows Service
    ... There is probably some way to debug this, but that's deeper Windows knowledge than I can dredge up right now. ... I looked into the Event Log and found that when my service ... 1st Login succeeds. ... You can try turning on login auditing in SQL Server and then check the ...
    (microsoft.public.sqlserver.connect)