How to Run a Silverlight enabled WCF Service Method as a Specific Domain User/Account
Posted on 2011-09-12
I am using Silverlight 4 and a Silverlight Enabled WCF Service. I have a Print button which makes an Async call to my service method. The goal here is to get my service to automatically print a report to a specific printer and drawer.
I have found the following...
I've read that impersonating all operations may increase attacks and negatively impact the security of your application. I simply want this one service method to impersonate. I found by adding this single line above my service method I'm now getting the list of printers on my machine and the report did print automatically to my default printer. THE PROBLEM IS I can't guarenteed the desired printer is the user's default and I don't want to hard code a printer name.
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
"The user running the web service (usually the system or ASPNET account) must have a printer installed and must have permissions to print to that printer. Typically it's easiest to create a Domain account to run the web service. Then you can log in as that account, create a printer and test printing."
Another person suggested... "You should get the identity of the current user at a point in the service when you are scanning printers. My guess is you are running as an anonymous user or someone other than your personal domain account. If this is the case you need to run the service as a specific domain user with access to these printers."
We are running our service authentication at:
Anonymous - Disabled
ASP.NET Impersonation - Disabled
Form Authentication - Disabled
Windows Authentication - Enabled
The following exists in the web.config:
<authentication mode="Windows" />
Anyone have any ideas as to how I can accomplish this WITHOUT automatically taking the current user's default printer or hard coding a printer name? How do I run a specific service method under a specific domain account/user?