Solved

Start a thread with different user in Delphi app

Posted on 2008-10-28
2
426 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

Why are Office 365 signatures so complicated?

Trying to setup transport rules for Office 365 email signatures and can’t quite figure it out? Having to test the signature over and over? Make things simple by using Exclaimer Cloud - Signatures for Office 365.

Question has a verified solution.

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

Suggested Solutions

The question has been asked on multiple occasions as to how best to do printing in a remote desktop or terminal services environment.   It seems that this particular question has plagued several people and most especially as Terminal Services, as…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

19 Experts available now in Live!

Get 1:1 Help Now