Solved

How do I change folder permission programatically which are grayed out

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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