Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ADsSecurity in VB6

Status
Not open for further replies.

adstam

Technical User
Feb 28, 2001
25
I am building an application in VB6 to create and maintain treestructures for projectarchiving.
A userwish is to get security on certain paths in the structure. Therefore i wish to copy the security of the samplestructure to the projectstructures. Use of (forexample) Robocopy to copy the security is not possible because the security on folders is not inherited by files.
Is there anyone who has used ADsSecurity for this kind of work (e.g. GET any securitycontrolentry from a folder to SET all securitycontrolentry's for a set of folders and files?

Used filesystem is NTFS, OS = W2K
 
ps

After searching around i have found the CopyACL function. Might someone help me with a sample to use this function???
 
Found the solution myself by combining several sources....

- Download the ADSI ResourceToolKit from microsoft (- Add adssecurity from the toolkit and Activeds.dll (Active DS Type Library) as references to your VB app.

Sample for copy ACL from one file (or folder) to an other:

Sub CopySec (SourceFile, TargetFile)
Dim sec As New ADsSecurity
Dim sd As IADsSecurityDescriptor
Dim dacl As IADsAccessControlList
Dim CopyDacl As IADsAccessControlList

Set sd = sec.GetSecurityDescriptor("FILE://" & SourceFile)
Set dacl = sd.DiscretionaryAcl

Set sd = sec.GetSecurityDescriptor("FILE://" & TargetFile)
Set CopyDacl = dacl.CopyAccessList
sd.DiscretionaryAcl = CopyDacl
sec.SetSecurityDescriptor sd


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top