views:

31

answers:

1

A WCF project consist of all the logic behind a desktop application (WPF) and it works well when I run it on VS 2008 with WCF selfhost. The desktop application consume services expose by the WCF and desktop application users have to login to the app using his username and password. WCF is connect with SQL Server 2008 database through LINQ and user account details also save in that database.

But after I host that WCF in IIS 7, when I login to the desktop application, it says username and password are not match. But It worked perfect in VS 2008 with self host before I host WCF in IIS 7. What is the reason for this behavior?

Please help me to solve this problem

Connection string for SQL Server database:

<add name="iSponsor.Data.Properties.Settings.test_dbConnectionString" 
     connectionString="Data Source=LMR-HERO\SQLSP1INS;Initial Catalog=test_db;Integrated Security=True" 
     providerName="System.Data.SqlClient" />
+1  A: 

You're using integrated security. That means that the WCF service will attempt to log into the database using the IIS application pool identity.

You will either need to

  1. grant the default app pool users (or more conveniently the local group IIS_IUSRS) permissions to access your database - needs carefully locked-down access, though, but very difficult for an attacker to impersonate this user
  2. run the application pool as a local or domain user who does have access to the database - again need to carefully lock down this user
  3. use SQL server authentication instead (username / password) - simplest to set up but easiest to attack
Rup
+1 well said - all the necessary info is there! :-)
marc_s
yes! it worked. I follow the first approach as Rup said and I just add a new user for sql server login called 'IIS APPPOOL\DefaultAppPool'. Then I give relevant permission to that user.thx for the support.
arlahiru