|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
printersettings.installedprinters in asp.net not working for non-domain webserver with network printWe 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 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? Show quote "Tessa" <nospam> wrote in message news:eGplviO8GHA.788@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 > 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 Show quote "Tessa" <nospam> wrote in message news:ekdp05X8GHA.940@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" <nospam> wrote in message > news:eGplviO8GHA.788@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 > > |
|||||||||||||||||||||||