473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Set DACL in folderwith NTFS.

I need to know how to set a DACL in a folder using NTFS in order to establish
the permissions for the folder, I have already acomplished this with a share
object but I also want to put security in the folder itself. The following
piece of code shows the way I have given the permissions to the share:

Dim Ace1, Ace2 As Management.ManagementObject
Dim scope As New Management.ManagementScope("\\localhost\root\cimv2 ")
'Set an ACE for the user
Ace1 = SetAce(scope, 2032127, 3, 0, SetTrustee(scope, "user",
UserName,UserSID))
Ace2 = SetAce(scope, 2032127, 3, 0, SetTrustee(scope, "user", "Admins. del
dominio", adminSID))
'Place the aces into a Win32_SecurityDescriptor
Dim secDescriptor As Management.ManagementObject
secDescriptor = New Management.ManagementClass(scope, New
Management.ManagementPath("Win32_SecurityDescripto r"),
Nothing).CreateInstance()
secDescriptor("ControlFlags") = 4
secDescriptor("DACL") = New Management.ManagementObject() {Ace1, Ace2}
Private Function SetTrustee(ByVal scope As Management.ManagementScope, ByVal
domain As String, ByVal name As String, ByVal UserSid As Byte()) As
Management.ManagementObject

Dim wmiTrustee As Management.ManagementObject
wmiTrustee = New Management.ManagementClass(scope, New
Management.ManagementPath("Win32_Trustee"), Nothing).CreateInstance()
wmiTrustee("Domain") = domain
wmiTrustee("Name") = name
wmiTrustee("SID") = UserSid
Return wmiTrustee

End Function

Private Function SetAce(ByVal scope As Management.ManagementScope, ByVal
accessMask As Integer, ByVal aceFlags As Integer, ByVal aceType As Integer,
ByVal wmiTrustee As Management.ManagementObject) As
Management.ManagementObject

Dim wmiAce As Management.ManagementObject
wmiAce = New Management.ManagementClass(scope, New
Management.ManagementPath("Win32_ACE"), Nothing).CreateInstance()
wmiAce("AccessMask") = accessMask
wmiAce("AceFlags") = aceFlags
wmiAce("AceType") = aceType
wmiAce("Trustee") = wmiTrustee
Return wmiAce

End Function
Nov 21 '05 #1
0 2247

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BingoHandJob | last post by:
Hello group! I'm having a problem and I hope some of you may be able to point me in the right direction. I inherited a web site using php, running on Windows 2000 & IIS. The site was...
2
by: travelling_nerd | last post by:
Folks: I have some zip files I'd like to serve to authenticated users on my site, but would like to prevent unauthorized users from using an absolute path to get to these zip files. For example...
3
by: Pål Andreassen | last post by:
Running Windows 2003 Server Framework 1.1 A site is configured to use integrated security (in IIS 6) Windows autentication and user impersonation in web.config <identity impersonate="true" />...
0
by: HitSkiper | last post by:
I am getting the error "The security ID structure is invalid." When running this code. Sub SetPermissions(ByRef vPath As String, ByVal UserName As String) Dim objADsSec As ADsSecurity Dim...
2
by: Jim Richards | last post by:
I have been told by a local PC club technician that 98SE cannot read NTFS drives in a network. Is this true? TIA, Jim.
3
by: Ray Cassick \(Home\) | last post by:
I am starting to think there is some kind of conspiracy :) but everywhere I try to locate some (working) code showing how to change NTFS partitions on a network share I end up at a dead end. I...
3
by: Brian Hampson | last post by:
I've swiped the following code pretty much directly from a technet article, and modified it for my purposes. Something isn't working. I'm trying to 1) create a share on a remote server...
0
by: =?Utf-8?B?ZGpj?= | last post by:
Hi all, im trying to replace a Dacl on a folder with a new one, or, delete some of the ace in the dacl using wmi, anyone have a eg on how to do this. Thanks
1
by: Jan Nielsen | last post by:
In a C# .Net web page I'm displaying some information from our AD. Furthermore I have a method allowing replacing a SID in an ACL of a user, group or computer object. I use the managedBy...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.