在Windows Server 2012中将用户添加到本地安全策略中

本文关键字:安全策略 添加 Windows Server 2012 用户 | 更新日期: 2023-09-27 17:49:38

使用LSA Functions Privileges and Impersonation中的代码

在Windows Server 2008R2上,将用户添加到登录作为服务策略可以正常工作。当在Windows Server 2012上使用此代码时,它不起作用。函数' lsaaddaccountryights '返回一个奇怪的数字,不能通过'LsaNtStatusToWinError'转换为窗口错误。返回代码类似于1034061105409818720。每次当我运行相同的代码时,它都会返回一个不同的数字。我被卡住了,有人能帮帮我吗?

在Windows Server 2012中将用户添加到本地安全策略中

最初使用的语句是:_私有共享函数lsaaddaccountryights (PolicyHandle As IntPtr, AccountSid As IntPtr, UserRights As LSA_UNICODE_STRING(), CountOfRights As Long) As Long结束功能

解决方法是将结果类型更改为UInt32。