Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 656
  • Last Modified:

Impersonated user and printing

Hi,

I have an app which is working under the name of a user account different from the currently logged on one, i.e. impersonated user account from a Windows domain. The account which my app is impersonating has been added to the local workstation and a default printer has been assigned to it. The currently logged on user also has the same printer set as a default one. However, when I try to print something I get a message 'There is no default printer'. If both accounts are equal then printing is always successful.

What is the problem and how could it be solved? I know I can revert to self, print and impersonate the user again but that's not I'm after. I hope there is a better solution.

Environment: Delphi 5 Ent, Win 2000/XP.

Thanks in advance.

Regards, Geo
0
geobul
Asked:
geobul
1 Solution
 
delphizedCommented:
if you use the delphi printer object and you don't have a default printer, then you don't have to use then

printer.printerindex:=-1;

instead select the appropriate printer with

printer.printerindex:=0; (if you have at least one printer installed of course);

or you could set the installed printer as the default printer in windows.
0
 
geobulAuthor Commented:
Thanks delphized. Setting

printer.printerindex:=-1;

before executing PrinterDialog solved it. It is not necessary to do so when printing from the currently logged on user. That's why I haven't added that line.

Regards, Geo
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now