I have a text file that the Local Administrator is the owner of the file.
When I am running the following code:
public static void CheckPermissions(string filePath)
{
FileSecurity acl = new FileInfo(filePath).GetAccessControl();
IdentityReference group = acl.GetGroup(typeof(SecurityIdentifier));
IdentityReference owner = acl.GetOwner(typeof(SecurityIdentifier));
}
It shows:
group = {S-1-5-21-<domain>-513} // DOMAIN_USERS group
owner = {S-1-5-21-<domain>-500} // Local Administrator
The GetGroup function according to Microsoft:
Gets the primary group associated with the specified owner.
But the primary group associated to the local administrator is Domain Users ?

I confused with the terms.
The
GetGroupfunction according to Microsoft:The
GetOwnerfunction according to Microsoft:So it seems that nothing was wrong with the question.
Just need to understand what meaning of the functions.
For example, the
GetGroupgets the primary group associated with the specified owner.So if the owner is for example the local administrators group, then the owner will be
SYSTEMand you will get:The primary group can't be seen through the GUI Windows. To change it, you need to use
SetGroup.