Rohit Pathak
Rohit Pathak

Reputation: 21

Unable to access SQL Server from WCF service (Windows authenticated) from client (console application) in C#

I'm using

  1. WCF service (Windows authenticated and impersonation)
  2. SQL Server (Windows authentication)
  3. Console application (client)

All are in the same domain.

I'm consuming a Windows authenticated WCF service from a console application as the client. However, when I try to access SQL Server from the console application using the WCF service, I get an error:

Exception In Account Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

My scenario is: my WCF service and SQL Server are on one system (System A) and my console application (my client) is on another system (System B).

When my client from System B sends a request, it hits my service successfully, but when the service tries to access SQL Server

Upvotes: 0

Views: 503

Answers (2)

Remus Rusanu
Remus Rusanu

Reputation: 294237

  • WCF service(Windows Authenticated and Impersonation)
  • Sql server(Windows Authentication)
  • Console Application(Client)

This scenario requires Kerberos constrained delegation. You cannot do this, you must enlist the help of a domain administrator to set it up for you. Read and follow How to Implement Kerberos Constrained Delegation with SQL Server.

Note that impersonation and delegation will flow the credentials of the original client (the console app) to the back end database, which means that you will need to grant SQL access to the actual users of your service, not to the WCF service account.

Upvotes: 1

Kay Lee
Kay Lee

Reputation: 952

I think your connection to WCF service has no problem but the SQL Server own security system perceives the client as a user beyond security barrier(like firewall) because the client is really from outside, not the administrator of the machine.

Why don't you apply the common idea that SQL authentification mode and asymmetric Encryption of Web.Config of WCF?

If you have to face situations that clients connect to Server from outside, Encryption(Security) is strongly recommended.

I have desktop application(WPF) on clients side and WCF service on Cloud service connecting to Cloud SQL Server.

Upvotes: 0

Related Questions