printersettings.installedprinters in asp.net not working for non-domain webserver with network print

T

Tessa

Hi,

We have a .net web application, and are trying to use
PrinterSettings.InstalledPrinters to list the printers installed on the
webserver. (Windows 2003 server R2, IIS 6, .net framework 2.0.)
The printers installed on the web server under the account used by asp.net
for this web application are network printers that are shared by other
computers that are on our domain. Permission has been granted for everyone
to print to them.
The web server running asp.net is not part of the domain, and the account
used by asp.net is a non-domain account. (It's the identity of the
application pool WEBSERVER\webappaccount).
From asp.net we can use PrintDocument.PrinterSettings.PrinterName to set the
printer name and then PrintDocument.Print works fine to these network
printers, however, when you use PrinterSettings.InstalledPrinters it
returns an empty collection, with no exception raised.

What could be preventing PrinterSettings.InstalledPrinters from being
populated, given that we can actually print from asp.net?

any help much appreciated

regards,
Tessa
 
T

Tessa

It looks like the same thing happens even if our web application is running
on a web server which IS in the domain as long as the asp.net identity being
used is a non-domain account.
If we use a webserver in the domain & a domain account for asp.net, then it
does find the network printers - this isn't an option for us in a live
environment for our clients, unfortunately.

How can a non-domain account print successfully to a printer shared by a
computer on a domain, but not find it in PrinterSettings.InstalledPrinters?
 
B

Bryan Phillips

You will have to write code to impersonate a domain user that has
permissions to print to the network printers and revert to the ASP.Net
identity afterwards. I print to network printers without referencing
the InstalledPrinters property. On another note, we careful about
accessing that property from a non-interactive process since it needs
access to the user's profile. Those types of activities can cause your
code to hang.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top