• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 576
  • Last Modified:

ASP.NET + Impersonating in Web Service

We have a webservice that exposes a public method with SoapDocumentMethod(OneWay:=True).  What is the identity it's using to process?  Web.config for the web service is set to imporsonate identity impersonate="true" userName="<username>" password="<password>" but it's not using it.

Keep getting the following error: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

If i remove SoapDocumentMethod(OneWay:=True) it seems to work, the reason i want this is i don't want the application to wait for the webservice to finish.
0
dkilby
Asked:
dkilby
  • 6
  • 5
1 Solution
 
ihenryCommented:
The error you're getting might be due to a problem with the SQL Server not being able to authenticate your web service security context and happens when the SQL Server is running on different machine. Can you explain a little bit more about IIS authentication method used? and it would be more helpful if you can print out the web service security context identity name so that you can tell what user account is actually being authenticated to the SQL Server.
0
 
dkilbyAuthor Commented:
Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=<database>;Data Source=<server>;Connect Timeout=1800;

the imperosonation is in the web.config

SQL Server is running on a different machine,  the thing i don't understand is if i remove SoapDocumentMethod(OneWay:=True) it seems to work.
0
 
ihenryCommented:
Can you post here the exception stack trace?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
dkilbyAuthor Commented:
From doing some other research it seems that the webservice is not reading the web.config, so if the webservice doesnt have access to HttpContext how else can it impersonate??
0
 
ihenryCommented:
are you using .NET Framework version 1.0?
0
 
dkilbyAuthor Commented:
Using v1.1.4322

Here is the error

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
DEVELOPMENT server connection string:Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=testDB_Dev;Data Source=sqlmachine;Connect Timeout=1800; Context Identity:  
0
 
ihenryCommented:
Let me guess, code in your webmethod is trying to connect to database with a connection string supplied from web.config. Do some debugging and check if you're able to get the connection string in the first place. Then, before open a connection to database print out Thread.CurrentPrincipal.Identity.Name and see what's the value.
0
 
dkilbyAuthor Commented:
but the connection string is showing up in the connection string
0
 
ihenryCommented:
I find your problem is weird since SoapDocumentMethodAttribute is unlikely to cause this kind of problem. Just need some more information, is the SQL Server in the same domain with your Web Server? are you login with domain account? and is your login account is enabled for delegation?
0
 
dkilbyAuthor Commented:
the sql server is on the same domain as the web server, i am logged in with domain account if the webservice can read the web.config file

The most confusing part is why it won't read the web.config when i have SoapDocumentMethod(OneWay:=True), i just tried running the app without it and it inserted data into the database no problem, as soon as i put it back i get the error.
0
 
ihenryCommented:
This problem had made me really curious. So I tried google to see if anyone has come across to the same problem. I found a few similar questions posted in some forums but unfortunately no solution at all. Now I think I'm really out of good idea. And my last suggestion for you is to post a new question which link to this so others who have more experience in this area can give you better help.
0
 
sachiekCommented:
I am bit curious to know why you are choosing this SoapDocumentMethod ?
SoapDocumentMethod will help your webservice to fire-and-forget kind of job.

Also can I know which WSE you are using ?Which version?

Sachi
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now