LogonUser

I use LogonUser in Delphi,why it always return false?
I tried it in Windows NT Workstation, Windows 2000 RC3.
qujbAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
as comments..
0
 
intheCommented:
you must have correct privilage before calling logonuser.
Here is an exemple of calling the EnablePrivilege function :
 
procedure TForm1.FormCreate(Sender: TObject);
var
  Error: Integer;
  ProcessToken: THandle;
begin
    if not OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES, ProcessToken) then
    begin
          Error := GetLastError;
          raise exception.create(SysErrorMessage(Error));
    end;
    if not EnablePrivilege(ProcessToken, 'SeTcbPrivilege', true) then     begin
          Error := GetLastError;
          raise exception.create(SysErrorMessage(Error));
    end;
    CloseHandle(ProcessToken);
end;

as a note see also the gina stuff at madshis site you may be interested in it:
http://nettrash.com/users/madshi/default.htm 

Regards Barry
 
0
All Courses

From novice to tech pro — start learning today.