BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ImpersonateUser RegistryConnect

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi WinAPI
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Oct 03, 2006 6:20 pm    Post subject: ImpersonateUser RegistryConnect Reply with quote



Hi there,

I am creating a CGI executable that runs under IIS. I have used
Windows Intergrated authentication so the CGI executable runs as a
specific user, rather than IUSR_SERVERNAME.

What the executable needs to do is impersonate another user
(administrator) and connect to a registry on another computer on the
network. This doesn't seem to work. RegistryConnect (part of the
TRegistry class) fails, and the registry calls end up looking at the
webserver machine.

Am I not approaching this in the right way or something? I think I
ought to work. Here's a code snippet (mostly taken from Delphi3000.com
and adapted)

function PerformLogon(const User, Domain, Password: String): Cardinal;
begin
if NOT LogonUser(pChar(User), pChar(Domain), pChar(Password),
LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT,
Result) then
RaiseLastWin32Error;
end;

hToken := PerformLogon('administrator','INTERNAL','password');
try
ImpersonateLoggedOnUser(hToken);
try

With TRegistry.Create do begin try
RootKey:=HKEY_LOCAL_MACHINE;
If Not RegistryConnect('\\'+ParamStr(2)) then
WriteLn('Failed to connect.');

....

This doesn't seem to work. Any suggestions?
Back to top
Riki Wiki
Guest





PostPosted: Thu Oct 05, 2006 4:59 am    Post subject: Re: ImpersonateUser RegistryConnect Reply with quote



On 3 Oct 2006 06:20:22 -0700, troggy (AT) gmail (DOT) com wrote:

Quote:
This doesn't seem to work. Any suggestions?

Hoi

You need to repost your question on the Borland news server to make
everybody see it and possibly answer your question. Further, this newsgroup
do not officially exist, use newsgroup b.p.d.nativeapi.win32.

How to post to Delphi newsgroups:
<http://delphi.wikia.com/wiki/Delphi_Newsgroups>
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi WinAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.