Printing From Web Service

Posted on 2004-11-12
Last Modified: 2010-05-18
I  have been pulling my hair out on this one for quite some time...any help would be appreciated!

I have a web service running on a Win 2000 Advanced Server. The service needs to print something on command from the client application to a NETWORK printer.

For some reason, when we send the print job, nothing happens. That is, no errors, nothing in the printer's queue, nothing.
I CAN print from the server using Notepad. So I know the printer works and the server can talk to it.

THe printer we are trying to print to is configured as the Default printer, and the printer is configured to allow Everyone to print from it.

One thing that I am thinking is that when noone is logged into the server, how do you configure a printer as the default for that case?  That is, when I login into the server, and set up a printer, I assume that it is setup for my user profile. But what happens when I log off and noone is logged in? How can I set the printer up for that case?

I also tried setting up a LOCAL printer that is mapped to the network port. We had success with this when developing the webservice on another PC using LocalHost for the server. But since we moved the code to a production web server...nothing.

Question by:ptakja
    LVL 10

    Accepted Solution

    This is probably a security problem, is the webservice running under the default account becuase this has no network access permissions by default. what you need to do is either set the webservice to run under an account with access to the network or you could set up impersonation for either the webservice or just the few lines of code to print. the later is far harder.
    This error would be consistent with the user being able to print and the webservice not as they use different accounts.

    hope that is of some help

    LVL 14

    Author Comment

    Thanks for the quick reply James. So how do I set the web service to run under a specific account?
    LVL 10

    Expert Comment


    if you add the following line to teh web.config file, this will set up impessonation for the entire section of code that web.config file is valid for.

    <identity impersonate="true" userName="[domain / machine name]\[username]" password="[password]"/>

    disadvantage is that you have to have the password in plain text, unless someone knows of a way not to. Having said that iis will not let users download .config files it returns a 404.

    Im afraid i dont have the code to hand for setting up 'inline' impersonation, might be worth a quite search of msdn.

    but if you set that up the impersonation as above as prove of concept you will at least be able to finger or eliminate the security issue.


    LVL 14

    Author Comment

    No luck. I put that line in with my credentials and retried my app.  Same thing. Also restarted IIS. Still nothing. :-(

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now