Solved

Start a thread with different user in Delphi app

Posted on 2008-10-28
2
425 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:
ciuly 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 36

Author Closing Comment

by:Geert Gruwez
ID: 31510716
thx ciuly
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now