Solved

Start a thread with different user in Delphi app

Posted on 2008-10-28
2
433 Views
Last Modified: 2010-04-21
I have this app run from the currently logged on user
(standard start double click from desktop)

In this windows app i want to create a thread using a diffent user.
This user obviously has more priviliges than the user starting the app.

This app is a tool to read from AD and perform changes in AD.
The secondary user would be used to do this.

I could off course start the app from the secondary user,
but i don't want to do this.

Any code examples in Delphi ?
0
Comment
Question by:Geert Gruwez
2 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 22821423
use ImpersonateLoggedOnUser

  if LogonUser(user, domain or empty string , pass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, h) then
  try
    if ImpersonateLoggedOnUser(h) then
    try
      do whatever as user
    finally
      if not RevertToSelf then// either this, or exit the thread
        showmessage(syserrormessage(getlasterror));
    end
    else
      showmessage(syserrormessage(getlasterror));
  finally
    closehandle(h);        
  end;

Open in new window

0
 
LVL 37

Author Closing Comment

by:Geert Gruwez
ID: 31510716
thx ciuly
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is my 3rd article on SCCM in recent weeks, the 1st (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_4466-A-beginners-guide-to-installing-SCCM2007-on-Windows-2008-R2-Server.html) dealing with installat…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

827 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