dkilby
asked on
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.
Keep getting the following error: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
If i remove SoapDocumentMethod(OneWay:
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.
ASKER
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.
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:
Can you post here the exception stack trace?
ASKER
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??
are you using .NET Framework version 1.0?
ASKER
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:
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:
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.Id entity.Nam e and see what's the value.
ASKER
but the connection string is showing up in the connection string
I find your problem is weird since SoapDocumentMethodAttribut e 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?
ASKER
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.
The most confusing part is why it won't read the web.config when i have SoapDocumentMethod(OneWay:
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
SoapDocumentMethod will help your webservice to fire-and-forget kind of job.
Also can I know which WSE you are using ?Which version?
Sachi