Solved

How do I change folder permission programatically which are grayed out

Posted on 2008-10-10
2
683 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

815 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

8 Experts available now in Live!

Get 1:1 Help Now