Hi
I am trying to connect to SQL server data base using NT authentication
from my window service code.

_bstr_t bstrConn =
_bstr_t("PROVIDER=SQLOLEDB;SERVER=SD1;DATABASE=MEDICAPT;TRUSTED_CONNECTION=YES;");

m_pConnGenGuiDB->ConnectionString = bstrConn;
m_pConnGenGuiDB->CommandTimeout = 600;
m_pConnGenGuiDB->Open("","","", adConnectUnspecified);

I am getting error Description = Login failed for user 'NT
AUTHORITY\SYSTEM'

The same code works fine in any MFC application.
Any body have clue abt that

RE: Thru Windows Service connecting to SQL server database using windo by AMDIRT

AMDIRT
Wed Aug 31 08:38:12 CDT 2005

The credentials that you have specified for the service does not have access
to the SQL server. Possibly you are using .\LocalHost.

Use a tracefile to peer into the exception thrown, or to output
system.security.principal.windowsidentity.current prior to connection.



"raku" wrote:

> Hi
> I am trying to connect to SQL server data base using NT authentication
> from my window service code.
>
> _bstr_t bstrConn =
> _bstr_t("PROVIDER=SQLOLEDB;SERVER=SD1;DATABASE=MEDICAPT;TRUSTED_CONNECTION=YES;");
>
> m_pConnGenGuiDB->ConnectionString = bstrConn;
> m_pConnGenGuiDB->CommandTimeout = 600;
> m_pConnGenGuiDB->Open("","","", adConnectUnspecified);
>
> I am getting error Description = Login failed for user 'NT
> AUTHORITY\SYSTEM'
>
> The same code works fine in any MFC application.
> Any body have clue abt that
>
>

Re: Thru Windows Service connecting to SQL server database using windows authentication by Paul

Paul
Wed Aug 31 09:46:28 CDT 2005

On 31 Aug 2005 02:35:58 -0700, "raku" <rnassa@gmail.com> wrote:

¤ Hi
¤ I am trying to connect to SQL server data base using NT authentication
¤ from my window service code.
¤
¤ _bstr_t bstrConn =
¤ _bstr_t("PROVIDER=SQLOLEDB;SERVER=SD1;DATABASE=MEDICAPT;TRUSTED_CONNECTION=YES;");
¤
¤ m_pConnGenGuiDB->ConnectionString = bstrConn;
¤ m_pConnGenGuiDB->CommandTimeout = 600;
¤ m_pConnGenGuiDB->Open("","","", adConnectUnspecified);
¤
¤ I am getting error Description = Login failed for user 'NT
¤ AUTHORITY\SYSTEM'
¤
¤ The same code works fine in any MFC application.
¤ Any body have clue abt that

By default Windows Services run under a local system account which wouldn't have access to the
network much less SQL Server. If you need to implement integrated security then your Windows Service
should run under a domain account that has the necessary permissions to log on to and access SQL
Server.


Paul
~~~~
Microsoft MVP (Visual Basic)