简体   繁体   中英

Windows Service SQL Server Windows Authentication

<add name="NuspayTransactionSecurityEntities" 
     connectionString="metadata=res://*/Security.NTPSecurity.csdl|res://*/Security.NTPSecurity.ssdl|res://*/Security.NTPSecurity.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.10.11;initial catalog=SP_PROCESSOR;persist security info=False;;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />
<add name="NPTransaction" 
     connectionString="metadata=res://*/Transaction.NPTransaction.csdl|res://*/Transaction.NPTransaction.ssdl|res://*/Transaction.NPTransaction.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.10.11;initial catalog=SP_PROCESSOR;persist security info=False;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />
<add name="CBCommon" 
     connectionString="metadata=res://*/Common.CBCommon.csdl|res://*/Common.CBCommon.ssdl|res://*/Common.CBCommon.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.168.10.11;initial catalog=SP_PROCESSOR;persist security info=True;persist security info=False;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient"/>
<add name="ApplicationServices" 
     connectionString="data source=192.168.10.11;initial catalog=SP_PROCESSOR;persist security info=True;persist security info=False;" 
     providerName="System.Data.SqlClient"/>

My problem is Windows authentication is not working if I use this application as a Windows service but it's working well in an IIS web application.

I believe the service account which has configured to run windows service does not permission to connect to SQL ?

If this is the case, you need to make sure the user under which the service is running has permissions within SQL .

If you look in System, Administrative Tools, Services and find your service. You can adjust the credentials associated with it.

When you run is IIS , the identity under which it is run is that of the app pool identity who's has permission to connect to SQL.

Often when we install services they install against the Network Service or Local System security principles. These shouldn't be given access to SQL.

You could also create an SQL user and use a connection string which implements SQL authentication instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM