views:

270

answers:

5

We are using classic asp to call a C# dll and in the C# dll we are using System.Drawing.Printing.PrinterSettings.InstalledPrinters to get a list of availabe printers. If the printers are not shared they will not show up when a user trys to print. The Local System account can see and print to them from a VB6 dll and Administrators can print just fine from the C# dll as you might expect. Is there some sort of permissions we need to grant the user so these printers will be available?

+2  A: 

As I recall, running a website uses the Network User account, which may not have permission to view local printers.

There was a page on MSDN that said how you can impersonate another user that might have access to the printers, but I've not been able to find it.

Edit: I posted too soon. Here's the page.

HTH

Tim Sullivan
A: 

I'm pretty sure it's running with the user's credentials. In SQL Profiler my queries are using the user's credentials. Granting the Network Service account access to the printer does not solve the problem.

Ryan
+1  A: 

I'm fairly certain that impersonating a user or using their credentials does not constitute the ability to see the printers for that user. I believe explorer.exe reconnects all the network resources (shares/printers) upon logon.

Joel Lucsy
A: 

@Joel Lucsy If it only connects when explorer.exe runs then why would the administrators be able to access the printers when no users are logged in?

Ryan
A: 

@Ryan I'm not sure what exactly you mean. Perhaps the administrator can do that because he himself is logged in, or because the printers that a particular user can see are stored as entries in the registry.

Joel Lucsy