Solved

setting time under NT from non Administrator Accounting

Posted on 2000-03-09
6
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

695 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