I'm curious if there's a way to prevent users (including the ones belonging to the admin group) from taking ownership of a file?
I originally create such file from my service that is running under Local System
account. I then set that file's DACL
to D:(A;OICI;GA;;;SY)
to let only SYSTEM
account to have full access, and set my service
as an owner:
DWORD dwRes = ::SetNamedSecurityInfo(
strDataFilePath,
SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION, // change only the object's owner
pMyServiceUserSid, // User SID for my service
NULL,
NULL,
NULL);
But after all that is done I can still take ownership of this file via Windows Explorer as an administrator: