Discussion:
ImpersonateUser RegistryConnect
(too old to reply)
t***@gmail.com
2006-10-03 13:20:22 UTC
Permalink
Raw Message
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?
Riki Wiki
2006-10-04 23:59:14 UTC
Permalink
Raw Message
Post by t***@gmail.com
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>

Loading...