A
Andreas Müller
Hi NG,
i am having some trouble on a Windows 2008 Small Business Server and the
UAC. For our application we have a tool to set up some system settings and
write a file with some configuration information which is used for the
clients.
Because of the system settings changes the application needs Administration
privileges so I included a manifest file with '<requestesExecutionLevel
level="requireAdministrator">'. This works very fine, the UAC comes up and
everything works.
BUT, in the code I use the methods "Directory.Create" and "File.Create". If
this code is executed in the "elevated mode" the new directories and files
do NOT inherit their privileges from the parent. It is totally crazy, but
under the "normal user account" the directories and files are not readable,
althought the parent folders (and other files) are visible and readable by
everbody.
For the directories I was able to find a workaround:
Directory.CreateDirectory(path,
new
System.Security.AccessControl.DirectorySecurity(Directory.GetParent(path).FullName,
System.Security.AccessControl.AccessControlSections.All));
If is use this code, the directories behave as expected, the security
settings are inherited automatically. But if I only use
Directory.CreateDirectory(path) nobody (except elevated processes) can read
the directory.
I could live with this, but I have the same problem for newly created files
and the DirectorySecurity object can not be used while creating files.
Is there any global option I can set to tell my C# process that every newly
created directory or file should inherit the security settings from the
parent.
By the way, when I remove the manifest and execute the application without
the elevation every directory and file is readable, but then of course some
other things relating administrativ tasks will not work.
Regards
Andreas
i am having some trouble on a Windows 2008 Small Business Server and the
UAC. For our application we have a tool to set up some system settings and
write a file with some configuration information which is used for the
clients.
Because of the system settings changes the application needs Administration
privileges so I included a manifest file with '<requestesExecutionLevel
level="requireAdministrator">'. This works very fine, the UAC comes up and
everything works.
BUT, in the code I use the methods "Directory.Create" and "File.Create". If
this code is executed in the "elevated mode" the new directories and files
do NOT inherit their privileges from the parent. It is totally crazy, but
under the "normal user account" the directories and files are not readable,
althought the parent folders (and other files) are visible and readable by
everbody.
For the directories I was able to find a workaround:
Directory.CreateDirectory(path,
new
System.Security.AccessControl.DirectorySecurity(Directory.GetParent(path).FullName,
System.Security.AccessControl.AccessControlSections.All));
If is use this code, the directories behave as expected, the security
settings are inherited automatically. But if I only use
Directory.CreateDirectory(path) nobody (except elevated processes) can read
the directory.
I could live with this, but I have the same problem for newly created files
and the DirectorySecurity object can not be used while creating files.
Is there any global option I can set to tell my C# process that every newly
created directory or file should inherit the security settings from the
parent.
By the way, when I remove the manifest and execute the application without
the elevation every directory and file is readable, but then of course some
other things relating administrativ tasks will not work.
Regards
Andreas