Solved

setting time under NT from non Administrator Accounting

Posted on 2000-03-09
6
213 Views
Last Modified: 2010-04-02
i need to set the sistem time without using NT Security (because my program will run on NT under non Admin login and it must have the possibility to set the system time!)

how can i do this?
and it's possible to do it?
(samples of source code are needed)

thanks

Cristian Bertoldi

i've posted the question under C section too. I will assign 500 points to the first correct answer.....
0
Comment
Question by:crisbert
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 2600576
This is possible by using an account that holds the 'SeSystemtimePrivilege' - there is no need to have an admin login. This privilege is usually granted to Administrators and Power Users, but can also be granted to 'normal' users, but granting privileges indeed needs an admin account (e.g. your installation program could do it).

If you could go this way, I could offer some samples.

Another alternative would be to use a service that sets the time, but this is much more work...
0
 

Author Comment

by:crisbert
ID: 2601704
ok , i'll try this way if you send me a sample...

thanks
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 2602000
http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/vcsmpisaprivssample.htm

and download the sample. The 'lsaprivs.c' file illustrates how to do it. Simply replace

        Status = SetPrivilegeOnAccount(
                    PolicyHandle,           // policy handle
                    pSid,                   // SID to grant privilege
                    L"SeServiceLogonRight", // Unicode privilege
                    TRUE                    // enable the privilege
                    );

from the sample with

        Status = SetPrivilegeOnAccount(
                    PolicyHandle,           // policy handle
                    pSid,                   // SID to grant privilege
                    L"SeSystemtimePrivilege", // Unicode privilege
                    TRUE                    // enable the privilege
                    );

and it should work...
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 32

Expert Comment

by:jhance
ID: 2602079
This question is also asked at:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=cprog&qid=10308047 

crisbert has said there that the option of changing user rights on the machine is not an option.  

An example to do this as a service is also included there.
0
 
LVL 86

Expert Comment

by:jkr
ID: 2602244
Sorry, didn't pay attention to this Q in the C area...
0
 

Author Comment

by:crisbert
ID: 2603779
thanks anyway, i'll use this sample code in another application....

if you have anything else......

Thanks
Cristian Bertoldi

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VS2015 compilation and missing DLLs 9 147
Safe conversion? 4 67
Embarcadero WebBroker REST server endpoint parameters 2 68
designing in object programming 12 77
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question