简体   繁体   English

托管将SQL数据库访问IIS的WCF服务

[英]Hosting WCF Service that accesses SQL database onto IIS

I have a WCF service that accesses a SQL database to fetch data . 我有一个WCF服务,可以访问SQL数据库以获取数据。 I would like to deploy this service onto IIS . 我想将此服务部署到IIS上。 However , when i do this , my service is not able to access the database . 但是,当我这样做时,我的服务无法访问数据库。 This is how my service accesses the DB 这就是我的服务访问数据库的方式

    SqlConnection thisConnection = new SqlConnection(@"user id=SAIESH\Saiesh Natarajan;" +
                                   "password=;server=SAIESH\\SQLEXPRESS;" +
                                   "Trusted_Connection=yes;" +
                                   "database=master; " +
                                   "connection timeout=30");

I need to know what i should do to be able to access this DB from my WCF service hosted on IIS 我需要知道我应该怎么做才能从IIS上托管的WCF服务访问此数据库。

Under IIS your service usually will be executed under NETWORK SERVICE account. 在IIS下,您的服务通常将在NETWORK SERVICE帐户下执行。 In your connection string you use trusted_connection=yes . 在您的连接字符串中,您使用trusted_connection=yes So, you need grant access to NETWORK SERVICE account. 因此,您需要授予对NETWORK SERVICE帐户的访问权限。 But better solution is to change authentication scheme and use USERNAME/PASSWORD to connect to SQL server. 但是更好的解决方案是更改身份验证方案,并使用USERNAME / PASSWORD连接到SQL Server。
Actually here is similar question WCF Impersonation and SQL trusted connections? 其实这里是类似的问题WCF模拟和SQL可信连接吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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