Directory / file release issue

I wrote some code to set folder permission. I have developed a function

public void SetPermission(string user,FileSystemRights rights)
{
    DirectoryInfo dInfo = new DirectoryInfo(folderPath);
    DirectorySecurity oDirectorySecurity = new DirectorySecurity();

    oDirectorySecurity.AddAccessRule(new FileSystemAccessRule(user, rights, AccessControlType.Allow));
    dInfo.SetAccessControl(oDirectorySecurity);
}

      

This function works fine to set permission for the user. But when I check the Properties -> Security folder, the user added. But the checkbox is not checked. Open an extended dialog. In this field, you can see the permission that I have set for the user.

So my question is, why is the checkbox not checked in the security tab, but it is in the advanced tab?

HELP HELP !!!!!!

+1


source to share


2 answers


I ran into this too. This seems to be a service patch.

You can read how I fixed it at http://jspot.jerryhanel.com/2009/01/08/c-filedirectory-permissions/

Short version: you must set the flag for all ACLs for all users. Yes ... it's ugly. And when you add Service Pack 3, the checkmarks disappear again. If anyone has a cleaner solution please let me know.



I have a code for this on my site.

UPDATE . The URL is now pointing to the new site.

+1


source


It might help to use dInfo.GetAccessControl to initialize oDirectorySecurity. You can also try calling oDirectorySecurity.SetOwner.



Sometimes, permissions are only displayed in advanced mode if they are not being applied to fix objects. Try setting the Inheritance / Propigration flags on the FileSystemAccessRule object.

0


source







All Articles