user1749979
user1749979

Reputation: 31

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?

Upvotes: 1

Views: 231

Answers (1)

user1749979
user1749979

Reputation: 31

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.

Upvotes: 1

Related Questions