views:

102

answers:

1

In our code, we have to give the users a list of printers to choose from. The user then chooses a printer and it is checked to verify it is valid before printing. On a windows 2003 server with IIS 6, this works fine. On a windows 2008 server with IIS 7, it fails each time impersonate is set to true.

PrinterSettings printerSetting = new PrinterSettings();
printerSetting.PrinterName = ddlPrinterName.SelectedItem.Text;
if (!printerSetting.IsValid)
{
    lblMsg.Text = "Server Printer is not valid.";
}
else
{
    lblMsg.Text = "Success";
}

Each time this code is run, the "Server Printer is not valid" displays, only if impersonate is set to true. If impersonate is set to false, the success message is displayed.

The impersonation user has full rights to the printer.

Is there a way to catch the actual reason the printer is not valid? Is there some other 2008 setting I should check?

update I found that IsValid fails when the IIS7 application pools has "Enable 32-bit applications" is checked. This must be checked b/c we are using a 3rd party tool to print with, and it is a 32-bit application. It is not currently part of this test, so right now it is not causing this error.

A: 

IIS 7.0 is really locked down. It sounds like the server is not impersonating properly. The printer profiles are stored in the HK_CURRENT_USER hive of the user or if it is a locally connected printer in the HK_LOCAL_MACHINE.

I would use PROCMON from SYSINTERNALS to see the calls the IIS process is making.

ggonsalv