Link to home
Start Free TrialLog in
Avatar of qujb
qujb

asked on

LogonUser

I use LogonUser in Delphi,why it always return false?
I tried it in Windows NT Workstation, Windows 2000 RC3.
Avatar of inthe
inthe

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
 
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial