I call the Advapi32.dll function LsaEnumerateAccountRights that has a policy descriptor from LsaOpenPolicy and an account SID from LookupAccountName.
However, try as I could, I always return 0xC0000034, which after translating LsaNtStatusToWinError gives me: "Linked file not found."
It's not very good. My code handles this and continues to provide the SID of the SeServiceLogonRight account with LsaAddAccountRights, so I know that the policy descriptor and SID of the account are fine, as this can pop up if something goes wrong with one of them.
The end result is that the account has the right solution, so that overall the code works.
However, I use this as part of a custom MSI action, Install checks to see if the account has the right, and if not (or it fails, as indicated above), it grants the right and remembers that it did so in the installation state. If a rollback occurs and he adds the right, he removes it. We never delete it when uninstalling, as other applications can be installed using the same domain account as the services we use.
So the problem is that MSI is rolling back - it will always delete the right, because it always considers that it has been added. Therefore, a rights check using LsaEnumerateAccountRights is used for this, but I just can't get it to work.
Any idea - note that I'm using C # with the DllImport attribute to expose Win32 functions, and I'm not the best Win32 programmer in the world who was Unix before C #!
security winapi
Alan mullett
source share