[英]Add user to local security policy on Windows Server 2012
When using the code from LSA Functions Privileges and Impersonation 使用LSA功能特权和模拟中的代码时
on Windows Server 2008R2 it works fine to add a user to the logon as a service policy. 在Windows Server 2008R2上,可以很好地将用户添加到登录即服务策略中。 When using this code on Windows Server 2012 it doesn't work. 在Windows Server 2012上使用此代码时,它将不起作用。 The function 'LsaAddAccountRights' returns an strange number which can't be translated via 'LsaNtStatusToWinError' to a windows error. 函数“ LsaAddAccountRights”返回一个奇怪的数字,该数字无法通过“ LsaNtStatusToWinError”转换为Windows错误。 The return code is something like 1034061105409818720. Every time when I run the same code, it returns a different number. 返回代码类似于1034061105409818720。每次运行相同的代码时,它都会返回不同的数字。 Can someone provide some help because I'm stuck? 有人会因为我被卡住而提供帮助吗?
The initial statement used was: _ Private Shared Function LsaAddAccountRights(PolicyHandle As IntPtr, AccountSid As IntPtr, UserRights As LSA_UNICODE_STRING(), CountOfRights As Long) As long End Function 使用的初始语句为:_私有共享函数LsaAddAccountRights(PolicyHandle为IntPtr,AccountSid为IntPtr,UserRights为LSA_UNICODE_STRING(),CountOfRights为长)作为长端函数
The solution was changing the result type into UInt32. 解决方案是将结果类型更改为UInt32。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.