Recently I posted class that I am using to Programmatically set IIS Authentication for a page. Later I found that initial implementation almost never worked because files in subfolders usually do not have explicit entries in the metabase, but inherit all properties from the parent. I've added code to create metabase entry (similar to this). But if the file is in subfolder, not in the virtual directory, adding the SchemaClassNames="IIsWebFile" doesn't work (see discussion Creating Virtual Directories using DirectoryEntry - HRESULT: 0x8000500F).
I've spend a lot of time triying to workaround this and finally ADSUTIL gave me a hint:
WARNING: The Object Type of this object was not specified or was specified as IIsObject.
This means that you will not be able to set or get properties on the object until the KeyType property is set.
The solution is to create object with SchemaClassName = "IIsObject" and then set
entry.Properties[“keyType“].Value = "IIsWebFile";
I've updated my class to fix the problem.