Take ownership using ADsSecurityUtility



Hi all,
When logged on to a machine with local admin privillages you are able
to take ownership on files/folders that you don't have permissions to,
and grant your self access to the files/folders. (Nessecery if you need
to clean up old homefolders etc.)
You can do this in the GUI whith Explorer, or with subinacl.exe.
I tried to do this using ADsSecurityUtility, but it seem I can only
take ownership of files/folders that I allready have permissions to.
Is this the useless way it works? Or have I missed something?
At the last row "SetSecurityDescriptor" I get: "Microsoft VBScript
runtime error: Permission denied"
Here is my code:
-------------------------------------

Set WshNetwork = WScript.CreateObject("WScript.Network")

set sec = CreateObject("ADsSecurityUtility")



ud = "h:\"

u = "kristina fors"

strDomain = "samhallit"

strPath = ud & u & "\My Documents"

own = WshNetwork.UserName



sec.SecurityMask = 1 'ADS_SECURITY_INFO_OWNER, 2=GROUP, 4=DACL,
8=SACL

Set sd = sec.GetSecurityDescriptor(strPath, 1, 1)

sd.owner = strDomain & "\" & own

msgbox sd.owner

sec.SecurityMask = 1

sec.SetSecurityDescriptor strPath, 1, sd, 1

.



Relevant Pages