SE_SYSTEMTIME_NAME 权限不存在 [英] SE_SYSTEMTIME_NAME privilege does not exists

查看:94
本文介绍了SE_SYSTEMTIME_NAME 权限不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 windows7 机器上的用户帐户(而不是管理员帐户)更改系统时间.为了改变系统时间,在这个link 我们需要有 SE_SYSTEMTIME_NAME 权限.这是我的python脚本.

I am trying to change the system time from a user account (not from admin account) on windows7 machine. In order to change the system time, it is mentioned in this link that we need to have SE_SYSTEMTIME_NAME privilege. Here is my python script.

import os,sys
import win32api
import win32security

priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess (), priv_flags)
privilege_id = win32security.LookupPrivilegeValue (None, "SE_SYSTEMTIME_NAME")
win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)])

win32api.SetSystemTime(2015,11,20,20,5,30,0,0)

但是当我执行此脚本时,出现以下错误.这是回溯.

But when i execute this script i am getting the following error. Here is the traceback.

Traceback (most recent call last):
  File "D:\Public\Script1.py", line 7, in <module>
    privilege_id = win32security.LookupPrivilegeValue (None, "SE_SYSTEMTIME_NAME")
error: (1313, 'LookupPrivilegeValue', 'A specified privilege does not exist.')

为什么我无法获得特定的特权.我做错了什么?

Why i couldn't able to acquire the particular privilege. What am i doing wrong?

推荐答案

您需要的字符串是"SeSystemtimePrivilege".

在 Windows 头文件中,它是这样定义的:

In Windows header files it's defined like this:

#DEFINE SE_SYSTEMTIME_NAME TEXT("SeSystemtimePrivilege")

看这里:

理想情况下,您的 Python 库会将这些字符串定义为命名常量.这是 Python 中常用的模式.

Ideally your Python library would define these strings as named constants. That's the usual pattern used in Python.

我已经回答了这个问题,但它仍然不起作用.

I've answered the question but it's still not going to work.

这是因为权限必须由管理员授予您,如果您没有权限,则不能直接打开它们,这将违反安全性.

This is because privileges must be granted to you by an administrator, you can't just turn them on on if you don't have them, that would be a violation of security.

要授予权限,请使用 GPEdit.msc 或 SecPol.msc.在 GPEdit.msc 中,选择计算机配置 -> Windows 设置 -> 安全设置 -> 本地策略 -> 用户权限分配.您可以在此处找到权限分配.

To grant the privilege, use GPEdit.msc or SecPol.msc. In GPEdit.msc, choose Computer Configuration -> Windows Settings -> Security Settings-> Local Policies -> User Rights Assignment. This is where you find privilege assignments.

您可以授予帐户或帐户所属的组更改系统时间"权限.

You can either grant the account, or a group the account belongs to, the "Change the System Time" right.

如果您只是希望计算机有正确的时间,请配置 Windows Internet 时间服务.

if you just want the computer to have the correct time, configure the windows internet time service instead.

控制面板 -> 日期和时间 -> Internet 时间选项卡.

Control Panel -> Date and Time -> Internet Time tab.

选中与 Internet 时间服务器同步"框如果未选择服务器,请选择time.windows.com"或pool.ntp.org".

Check the box "Synchronise with an internet time server" If no server is selected choose either "time.windows.com" or "pool.ntp.org".

这将每周自动设置一次时间,这将使您的计算机保持在正确时间的几秒钟内.如果您正在运行一个重要的服务器,您可能需要更频繁地设置它.为此,您需要编辑注册表.

This will automatically set the time once per week, which should keep your computer within a few seconds of the correct time. If you are running an important server you may need to set it more often. To do that you need to edit the registry.

转到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient,并检查值 SpecialPollInterval.这是在几秒钟内.

Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\ NtpClient, and check the the value SpecialPollInterval. This is in seconds.

默认为 604800,即一周的秒数.对于每日时间检查,请选择 84600.除非您有非常特殊的要求,否则不会超过每天.

The default is 604800, which is the number of seconds in a week. For daily time checks, choose 84600. Unless you have very special requirements you won't need more than daily.

这篇关于SE_SYSTEMTIME_NAME 权限不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆