Solved

How do I change folder permission programatically which are grayed out

Posted on 2008-10-10
2
680 Views
Last Modified: 2012-05-05
I need to programatically remove permissions from the a user's Desktop folder on Windows Server 2003.  My problem is that when the user's profile is created, the desktop folder permissions are grayed out because they are inherited and therefore ignore any attempt of my code to edit them.  IF I manually uncheck the "Inherit from parent..." box, then the code works fine.  How can I overcome this, and if necessary, uncheck the inheritance box by code?   My VB.Net code is attached:


Dim dInfo As New DirectoryInfo(DirectoryName)
 

Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()

     

dSecurity.RemoveAccessRule(New FileSystemAccessRule(Account, Rights, ControlType))
 

dInfo.SetAccessControl(dSecurity)

Open in new window

0
Comment
Question by:itsupportgoodwill
2 Comments
 
LVL 31

Accepted Solution

by:
Henrik Johansson earned 500 total points
ID: 22692291
You can't remove inherited permissions without breaking/unticking the inheritance option.

See if JSI Tip 8225 helps
http://windowsitpro.com/article/articleid/81268/jsi-tip-8225-the-extended-change-access-control-list-tool-xcaclsvbs-has-been-enhanced-and-replaces-xcaclsexe.html
0
 
LVL 1

Author Closing Comment

by:itsupportgoodwill
ID: 31505233
That's just what I needed.  Thank you
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now