?
Solved

Impersonated user and printing

Posted on 2004-03-25
2
Medium Priority
?
649 Views
Last Modified: 2007-12-19
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
Comment
Question by:geobul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
delphized earned 2000 total points
ID: 10684844
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
 
LVL 17

Author Comment

by:geobul
ID: 10685278
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question