Rob wrote:
> Are you in charge of the server, or is it managed by a hosting company?

Yes we are in charge of the server.
I run secpol.msc in Win2000 pro machine I see by experiments that if I add
the user to
"Act as part of the operating system" the program will work after system
re-start!!


> See what you can do about acquiring the SeDebugPrivilege.

I copied the following code form IdGlobal (IdGlobalProtocols v10) with some
modifications:
    if not Windows.OpenProcessToken(GetCurrentProcess(),
                 TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
              hToken) then
    begin
      ShowMessage('Can''t open process token');
      exit;
    end;
    Windows.LookupPrivilegeValue(nil, 'SeDebugPrivilege',
tkp.Privileges[0].Luid);
    // LookupPrivilegeValue is not checked in INDY either
    tkp.PrivilegeCount := 1;
    tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
    if not Windows.AdjustTokenPrivileges(hToken, FALSE, tkp, sizeof(tkp),
tpko, buffer) then
    begin
      exit;
    end;

  lastError:=NoError;
  if LogonUser(PChar(PERMISSIBLE_USERNAME), //UserName
               nil,//PChar(GetDomainName)  nil means search in all domains
               PERMISSIBLE_PASSWEORD, //Password
               LOGON32_LOGON_INTERACTIVE,
               LOGON32_PROVIDER_DEFAULT,
               logonHandle) then begin
                   if ImpersonateLoggedOnUser(logonHandle) then begin
                   ///////////////////////////////////////////////////////
                   //////Do the hard task here///////
                   ///////////////////////////////////////////////////////
                   end
                   else begin
                     lastError := GetLastError;
                   end;
  end
  else lastError := GetLastError;
  If lastError<>NoError then
    ShowMessage(SysErrorMessage(lastError));

  if SysUtils.Win32Platform = VER_PLATFORM_WIN32_NT then
  begin
    Windows.AdjustTokenPrivileges(hToken, FALSE,tpko, sizeOf(tpko), tkp,
Buffer);
    Windows.CloseHandle(hToken);
  end;

 if logonHandle<> nil then begin
    lastError:=NoError;
    if not RevertToSelf then
            lastError := GetLastError;
    CloseHandle(logonHandle);
    If lastError<>NoError then
      ShowMessage(SysErrorMessage(lastError));
  end;

>The article I
> linked to should have demonstrated the code for doing that. Depending on
> what's allowed on the server, the code still might not work.

Which article ? Nothing was linked in your messages! Right?


Monir



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to