all groups > dotnet sdk > october 2006 >
You're in the

dotnet sdk

group:

CreateDirectory bug ?


CreateDirectory bug ? Jos Scherders
10/11/2006 11:33:02 PM
dotnet sdk:
Hi all,

I am having a problem with the Directory.CreateDirectory method. I want to
use this function to create a new directory and set a security descriptor at
the same time.
This works fine except the new directory never inherits aces from it's
parent.
For example:

CreateDirectory("mydir", directorySecurity) results in a directory with no
aces inherited.

but

dirInfo = CreateDirectory("mydir");
dirInfo.SetAccessControl(directorySecurity) results in a directory with
aces inherited.

Does this make sense to anyone ? It seems like this api is broken.

Thanks for any information on this.

Jos

RE: CreateDirectory bug ? VJain
10/13/2006 2:17:02 AM
yest it is breaking API
--
VJain


[quoted text, click to view]
Re: CreateDirectory bug ? Graham M
11/17/2006 1:26:13 AM
I am also getting the same problem. When I create a new directory with a DirectorySecurity object applied, the permissions are set correctly. However, when I use SetAccessControl with the same DirectorySecurity object. The parent folders users are copied in and the "Inherit permissions from parent folder" checkbox is checked. IS this a true bug or are my methods incorrect??? Have you resolved the issue since the last post. See below for my code:

private static DirectorySecurity CreateDirectorySecurity(string[] UserNames)
{
try
{
// Get a DirectorySecurity object that represents the current security settings
DirectorySecurity ds = new DirectorySecurity();

foreach (string UserName in UserNames)
{
// Add the FileSystemAccessRule to the security settings
ds.AddAccessRule(new FileSystemAccessRule(UserName,
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
}

return ds;
}
catch (Exception ex)
{
Utility.LogException(ex);

return null;
}
AddThis Social Bookmark Button