farminsure
asked on
How to Run a Silverlight enabled WCF service as a Specific Domain User
I am using Silverlight 4 and a Silverlight Enabled WCF Service. I have a Print button which makes an Async call to my service...see service code below. The goal here is to get my service to automatically print a report to a specific printer and drawer.
Using a Printer Settings object, it is listing the installed print devices for the service, which are not the printers installed on my machine.
We have found the following... "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
How can I run the service as a specified domain user?
//SERVICE CODE BELOW
[OperationContract]
public void PrintFormLetter(FormLetter Reports reportInformation)
{
try
{
if (PolicyAdminManager.CanSen dFormLette rs() == true)
{
FormLetterBasic flb = new FormLetterBasic(reportInfo rmation); // creates the report
System.Drawing.Printing.Pr interSetti ngs printSettings = new System.Drawing.Printing.Pr interSetti ngs();
printSettings.PrinterName = "Snagit 9";
ReportProcessor reportProcessor = new ReportProcessor();
reportProcessor.PrintContr oller = new System.Drawing.Printing.St andardPrin tControlle r();
reportProcessor.PrintRepor t(flb, printSettings);
}
}
catch (Exception e)
{
this.LogError(e, "PrintFormLetter");
throw e;
}
}
Using a Printer Settings object, it is listing the installed print devices for the service, which are not the printers installed on my machine.
We have found the following... "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
How can I run the service as a specified domain user?
//SERVICE CODE BELOW
[OperationContract]
public void PrintFormLetter(FormLetter
{
try
{
if (PolicyAdminManager.CanSen
{
FormLetterBasic flb = new FormLetterBasic(reportInfo
System.Drawing.Printing.Pr
printSettings.PrinterName = "Snagit 9";
ReportProcessor reportProcessor = new ReportProcessor();
reportProcessor.PrintContr
reportProcessor.PrintRepor
}
}
catch (Exception e)
{
this.LogError(e, "PrintFormLetter");
throw e;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Found my own solution.
Technically that's not what you've asked :)
How can I run the service as a specified domain user
<system.web>
<identity impersonate="true" userName="SomeUser" password="Password" />
<authentication mode="Windows"/>
</system.web>