472,791 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

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

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
Oct 16 '06 #1
2 6135
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?

"Tessa" <nospamwrote in message
news:eG*************@TK2MSFTNGP05.phx.gbl...
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

Oct 16 '06 #2
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


"Tessa" <nospamwrote in message
news:ek*************@TK2MSFTNGP03.phx.gbl:
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?

"Tessa" <nospamwrote in message
news:eG*************@TK2MSFTNGP05.phx.gbl...
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
Oct 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BJS | last post by:
Sorry for the cross-posting, but based on the number of people I have seen ask for a solution to this problem, I hope by cross-posting this, that it will help a lot of people out of a common...
3
by: RBisch | last post by:
I am finding that some of the properties off of the PrinterSettings object are misleading For example, When I test the CanDuplex on a printer I know duplexes, the property is false. Another one...
3
by: Steve Hanna | last post by:
I am having problems using the Printer Dialog to set PrinterSettings, specifically the landscape property of the DefaultPageSettings. Here's the code: <code> Private Sub GetPrinter(ByRef...
3
by: Jochen Kalmbach | last post by:
Hello, if an PrinterSettings-Instance is not set-up correctly (for example just by using the default-constructor), then the "ToString()"_method will throw an exception! Unhandled...
2
by: Robert Hooker | last post by:
Hi, I'm curious to know if I'm doing something wrong here, or if this is just mind-numbingly slow for a reason. In a simple WindowsFormsApplication: public Form1() { // Required for...
0
by: trint | last post by:
try { // Wait for the report to completely render. if(m_numberOfPages < 1) return false; PrinterSettings printerSettings = new PrinterSettings(); printerSettings.MaximumPage = m_numberOfPages;...
3
by: trint | last post by:
Can someone help me to get this code to work...I'm unsure what the 'printDoc' variable is supposed to be? // Add list of paper sources found on the printer to the combo box. // The DisplayMember...
0
by: Just Me | last post by:
I know that if mPD is a PrintDocument then these two are not equal mPD.DefaultPageSettings mPD.PrinterSettings.DefaultPageSettings But I need a quick description when each is used. Also:...
0
by: Craig Scheets | last post by:
I'm familiar with the shortcoming of 1.0/1.1 where the PrinterSettings class cannot be serialized. Is this fixed in Framework 2.0? I may upgrade the project I'm working on if that's the case, I...
2
by: =?Utf-8?B?RGF2aWQ=?= | last post by:
I’m not sure how to feed PCL commands (i.e. “Ec&l1S”) thru the PrinterSettings() function, but we have been successfully using the PrinterSetting() properties and methods to successfully call...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.