When setting ACL on folder it is inherating the shared setting as well

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am working on an app that creates home folders for new users which is working except when I go look at the folders it is creating the are showing up as shared and should not be. I found out that if i unshare the folder the parent folder and create another
user folder it does not show as shared.
To clarify on the D drive we have a folder called HomeDirs it is shared and has special permissions that make folders show up how we want. When I create a folder called test using my program it puts full permissions for the user on the test folder but it
also shows the test folder as shared when you click on the folder name. This is server 2008R2 where it tells you down at the bottom. Here is the really odd part about it while it says "State: Shared" it is not listed in the shared folders mmc or share and
storage management mmc but if I right click it and pick share with nobody the shared state does go away.
This is my code for setting the ACL permissions

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; void FolderACL(String accountName, String folderPath)
{
<span style="color:Blue; bool modified;

FileSystemRights Rights;

Rights = FileSystemRights.FullControl;
InheritanceFlags none = <span style="color:Blue; new InheritanceFlags();
none = InheritanceFlags.None;

<span style="color:Green; //set on dir itself
FileSystemAccessRule accessRule = <span style="color:Blue; new FileSystemAccessRule(accountName, Rights, none, PropagationFlags.NoPropagateInherit, AccessControlType.Allow);
DirectoryInfo dInfo = <span style="color:Blue; new DirectoryInfo(folderPath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.ModifyAccessRule(AccessControlModification.Set, accessRule, <span style="color:Blue; out modified);
dInfo.SetAccessControl(dSecurity);
}
[/code]

<br/>
Really all I need it to do is inherit the permissions of the parent (but not say shared) and let me assign ownership of the folder to the new user but it appears from what I have seen setting ownership doesnt work? So instead I just want to create the folder
which works fine and then give them full control of it and anything created in it.



View the full article
 
Back
Top