简体   繁体   中英

Add user to local security policy on Windows Server 2012

When using the code from LSA Functions Privileges and Impersonation

on Windows Server 2008R2 it works fine to add a user to the logon as a service policy. When using this code on Windows Server 2012 it doesn't work. The function 'LsaAddAccountRights' returns an strange number which can't be translated via 'LsaNtStatusToWinError' to a windows error. The return code is something like 1034061105409818720. Every time when I run the same code, it returns a different number. 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

The solution was changing the result type into UInt32.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM