Cannot use SetSystemTime Function without Admin permission

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I'm VB .NET developer and I'm implementing the application that can set the
system clock. So I would like everyone can automatically set the system time
when startup the application even the user that not have the privilege (not
administrator).

I use the AdjustTokenPrivileges method to change to privilege of the user. I
have problem when set the system time by SetLocalTime mothod from Win32 API
by user (Restrict User) is not in Administrative group, the user in
administrative group is work fine.

Questions:
1. Is the SetLocalTime method require the Administrator permission but I
can't see the comment on MSDN help, just comment about privilege that I
already done.
2. Or I'm not success to set the privilege of user because it need the
Administrator permission?
3. If above functions need the Adminisatrative permission how possible that
I can implement without Admin permission.
4. Is there anyway to set system time without logged-in by user in
Administrative group.

Cheers,
KPH
 
So I would like everyone can automatically set the system time
when startup the application even the user that not have the privilege (not
administrator).

Forget it, there's obviously no API to circumvent the system security.

SetSystemTime/SetLocalTime will only work for users that have been
granted the right to set the system time (and that can include
non-admins even if it doesn't by default).



Mattias
 
Hi Mattias,

I have already set system time privilege to the current process. I try to
debug the program both admin and debug user, the former is work fine but the
latter return false by SetLocalTime function.

Both user pass the routine set Privilege by AdjustTokenPrivilege function
but cannot pass the SetLocalTime routine.

Thanks,
KPH
 
I have already set system time privilege to the current process.

Do you mean with AdjustTokenPrivilege? You can only use that to enable
privileges that the user is already granted.



Mattias
 
Back
Top