Solved

setting time under NT from non Administrator Accounting

Posted on 2000-03-09
6
193 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
Comment Utility
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
Comment Utility
ok , i'll try this way if you send me a sample...

thanks
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 32

Expert Comment

by:jhance
Comment Utility
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
Comment Utility
Sorry, didn't pay attention to this Q in the C area...
0
 

Author Comment

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

if you have anything else......

Thanks
Cristian Bertoldi

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now