K
KeithM
[xposted to microsoft.public.dotnet.languages.csharp]
Hi,
I have a program that once used xcacls to set permissions on a folder.
I have now migrated from .NET 1.1 onto 2.0 and trying to use the
FileSystemRights, FileSystemAccessRule and DirectorySecurity classes to
manipulate permissions directly instead of calling out to xcacls.
Using the 'FileSystemRights.Write' permission I can apply the permissions to
the folder such that when using windows explorer to examine the properties I
can see the WriteData, AppendData, WriteExtendedAttributes and
WriteAttributes flags are all ticked when I look under 'advanced'[1].
This is the same as if I had applied the 'Write' permission manually using
explorer Security tab[2].
However when I have applied the permissions from C# code, if I then check
the properties in explorer for that folder, in the first window that appears
in Windows Explorer after bringing up properties and selecting the Security
tab, then highlight the user account I have applied the permissions for, in
the lower window labelled "Permissions for xyz", the "Write" box is not
ticked.
The special Permissions button is ticked but greyed out.
This behaviour is causing problems with other applications that seem to be
interrogating this "Write" permission on the security tab and then not
finding it set even though I have set exactly the same permissions that are
set if applied manually via explorer.
Can anyone explain what I need to do in the code to achieve the correct
behaviour?
[1] select folder of interest, right click, select properties, select
security tab, select user account of interest, select advanced button, on
next dialog, select same user account then click 'edit...' button
[2] select folder of interest, right click, select properties, select
security tab.
Hope this is clear.
The C# code I have currently is as follows:
FileSystemAccessRule access = new FileSystemAccessRule("account",
FileSystemRights.Write,
AccessControlType.Allow);
DirectorySecurity security = Directory.GetAccessControl("path of folder");
security.AddAccessRule(access);
Directory.SetAccessControl("path of folder", security);
(ignore any typos, this code runs ok)
Thanks
Hi,
I have a program that once used xcacls to set permissions on a folder.
I have now migrated from .NET 1.1 onto 2.0 and trying to use the
FileSystemRights, FileSystemAccessRule and DirectorySecurity classes to
manipulate permissions directly instead of calling out to xcacls.
Using the 'FileSystemRights.Write' permission I can apply the permissions to
the folder such that when using windows explorer to examine the properties I
can see the WriteData, AppendData, WriteExtendedAttributes and
WriteAttributes flags are all ticked when I look under 'advanced'[1].
This is the same as if I had applied the 'Write' permission manually using
explorer Security tab[2].
However when I have applied the permissions from C# code, if I then check
the properties in explorer for that folder, in the first window that appears
in Windows Explorer after bringing up properties and selecting the Security
tab, then highlight the user account I have applied the permissions for, in
the lower window labelled "Permissions for xyz", the "Write" box is not
ticked.
The special Permissions button is ticked but greyed out.
This behaviour is causing problems with other applications that seem to be
interrogating this "Write" permission on the security tab and then not
finding it set even though I have set exactly the same permissions that are
set if applied manually via explorer.
Can anyone explain what I need to do in the code to achieve the correct
behaviour?
[1] select folder of interest, right click, select properties, select
security tab, select user account of interest, select advanced button, on
next dialog, select same user account then click 'edit...' button
[2] select folder of interest, right click, select properties, select
security tab.
Hope this is clear.
The C# code I have currently is as follows:
FileSystemAccessRule access = new FileSystemAccessRule("account",
FileSystemRights.Write,
AccessControlType.Allow);
DirectorySecurity security = Directory.GetAccessControl("path of folder");
security.AddAccessRule(access);
Directory.SetAccessControl("path of folder", security);
(ignore any typos, this code runs ok)
Thanks