?
Solved

How do I change folder permission programatically which are grayed out

Posted on 2008-10-10
2
Medium Priority
?
692 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
Henrik Johansson earned 1500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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