?
Solved

How to Run a Silverlight enabled WCF service as a Specific Domain User

Posted on 2011-09-06
4
Medium Priority
?
629 Views
Last Modified: 2012-05-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...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(FormLetterReports reportInformation)
        {
            try
            {
                if (PolicyAdminManager.CanSendFormLetters() == true)
                {

                    FormLetterBasic flb = new FormLetterBasic(reportInformation); // creates the report

                    System.Drawing.Printing.PrinterSettings printSettings = new     System.Drawing.Printing.PrinterSettings();
                    printSettings.PrinterName = "Snagit 9";

                    ReportProcessor reportProcessor = new ReportProcessor();
                    reportProcessor.PrintController = new System.Drawing.Printing.StandardPrintController();

                    reportProcessor.PrintReport(flb, printSettings);
                }
            }
            catch (Exception e)
            {
                this.LogError(e, "PrintFormLetter");
                throw e;
            }
        }

 
0
Comment
Question by:farminsure
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:zvytas
ID: 36489331
You'll need to add the following to the web.config for the service:

    <system.web>
        <identity impersonate="true" userName="SomeUser" password="Password" />
        <authentication mode="Windows"/>
    </system.web>
0
 

Accepted Solution

by:
farminsure earned 0 total points
ID: 36490240
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! Thanks for your help though.

[OperationBehavior(Impersonation = ImpersonationOption.Required)]
0
 

Author Closing Comment

by:farminsure
ID: 36518393
Found my own solution.
0
 
LVL 5

Expert Comment

by:zvytas
ID: 36490881
Technically that's not what you've asked :)

How can I run the service as a specified domain user
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question