Jump to content

Using SetACL.ocx to return the owner of a file or folder.


PowerCat
 Share

Recommended Posts

A small snippet using SetACL.ocx which uses the list action

Hopefully it can help someone out there!

$path = "c:\windows\system32"

;SetACL $ACCESS Modes
Const $DENY_ACCESS = 3
Const $GRANT_ACCESS = 1
Const $REVOKE_ACCESS = 4
Const $SET_ACCESS = 2
Const $SET_AUDIT_FAILURE = 6
Const $SET_AUDIT_SUCCESS = 5

;SetACL Actions
Const $ACTN_ADDACE = 1
Const $ACTN_CLEARDACL = 16
Const $ACTN_CLEARSACL = 32
Const $ACTN_COPYDOMAIN = 1024
Const $ACTN_COPYTRUSTEE = 1024
Const $ACTN_DOMAIN = 8192
Const $ACTN_LIST = 2
Const $ACTN_REMOVEDOMAIN = 512
Const $ACTN_REMOVETRUSTEE = 512
Const $ACTN_REPLACEDOMAIN = 256
Const $ACTN_REPLACETRUSTEE = 256
Const $ACTN_RESETCHILDPERMS = 128
Const $ACTN_RESTORE = 2048
Const $ACTN_SETGROUP = 8
Const $ACTN_SETINHFROMPAR = 64
Const $ACTN_SETOWNER = 4
Const $ACTN_TRUSTEE = 4096

;SetACL Inheritance Values
Const $INHPARCOPY = 2
Const $INHPARNOCHANGE = 0
Const $INHPARNOCOPY = 4
Const $INHPARYES = 1

;SetACL $LIST Formats
Const $LIST_CSV = 1
Const $LIST_SDDL = 0
Const $LIST_TAB = 2

;SetACL $LIST Names
Const $LIST_NAME = 1
Const $LIST_NAME_SID = 3
Const $LIST_SID = 2

;SetACL Recursion
Const $RECURSE_CONT = 2
Const $RECURSE_CONT_OBJ = 6
Const $RECURSE_NO = 1
Const $RECURSE_OBJ = 4

;SetACL Return COdes
Const $RTN_ERR_ADD_ACE = 32
Const $RTN_ERR_CONVERT_SD = 27
Const $RTN_ERR_COPY_ACL = 31
Const $RTN_ERR_CREATE_SD = 45
Const $RTN_ERR_DEL_ACE = 30
Const $RTN_ERR_DIS_PRIV = 13
Const $RTN_ERR_EN_PRIV = 12
Const $RTN_ERR_FINDFILE = 16
Const $RTN_ERR_GENERAL = 2
Const $RTN_ERR_GET_SD_CONTROL = 17
Const $RTN_ERR_GETSECINFO = 5
Const $RTN_ERR_IGNORED = 44
Const $RTN_ERR_INTERNAL = 18
Const $RTN_ERR_INV_DIR_PERMS = 7
Const $RTN_ERR_INV_DOMAIN = 43
Const $RTN_ERR_INV_PRN_PERMS = 8
Const $RTN_ERR_INV_REG_PERMS = 9
Const $RTN_ERR_INV_SHR_PERMS = 11
Const $RTN_ERR_INV_SVC_PERMS = 10
Const $RTN_ERR_INVALID_SD = 38
Const $RTN_ERR_LIST_ACL = 28
Const $RTN_ERR_LIST_FAIL = 15
Const $RTN_ERR_LIST_OPTIONS = 26
Const $RTN_ERR_LOOKUP_SID = 6
Const $RTN_ERR_LOOP_ACL = 29
Const $RTN_ERR_NO_LOGFILE = 33
Const $RTN_ERR_NO_NOTIFY = 14
Const $RTN_ERR_OBJECT_NOT_SET = 4
Const $RTN_ERR_OPEN_LOGFILE = 34
Const $RTN_ERR_OS_NOT_SUPPORTED = 37
Const $RTN_ERR_OUT_OF_MEMORY = 46
Const $RTN_ERR_PARAMS = 3
Const $RTN_ERR_PREPARE = 24
Const $RTN_ERR_READ_LOGFILE = 35
Const $RTN_ERR_REG_CONNECT = 21
Const $RTN_ERR_REG_ENUM = 23
Const $RTN_ERR_REG_OPEN = 22
Const $RTN_ERR_REG_PATH = 20
Const $RTN_ERR_SET_SD_DACL = 39
Const $RTN_ERR_SET_SD_GROUP = 42
Const $RTN_ERR_SET_SD_OWNER = 41
Const $RTN_ERR_SET_SD_SACL = 40
Const $RTN_ERR_SETENTRIESINACL = 19
Const $RTN_ERR_SETSECINFO = 25
Const $RTN_ERR_WRITE_LOGFILE = 36
Const $RTN_ERR_OK = 0
Const $RTN_ERR_USAGE = 1

;SetACL $SD Info
Const $ACL_DACL = 1
Const $ACL_SACL = 2
Const $SD_GROUP = 8
Const $SD_OWNER = 4

;SetACL $OBJECT Types
Const $SE_FILE_OBJECT = 1
Const $SE_LMSHARE = 5
Const $SE_PRINTER = 3
Const $SE_REGISTRY_KEY = 4
Const $SE_SERVICE = 2

$SetACL1 = ObjCreate("SetACL.SetACLCtrl.1")

If IsObj($SetACL1) then

With $SetACL1
  $nError = .SetObject($path, $SE_FILE_OBJECT)
  $nError = .SetAction($ACTN_LIST)
  $nError = .SetListOptions($LIST_CSV, $SD_OWNER, "false", $LIST_NAME)
  $nError = .Run
  $nError = .GetLastListOutput()
Endwith

Else 
    Msgbox(0,"Error","No Object Found")
EndIf

ConsoleWrite($nError & @CRLF)
Edited by PowerCat
Link to comment
Share on other sites

which version do you use ?

I wanted to try and have downloaded one on sourceforge.net but when i want to register it i get an error message

LoadLibrary("C:\Documents and Settings\Administrateur\Bureau\SetACL 2.2.1\SetACL 2.2.1\COM version\x86 \SetACL.ocx") a échoué

Le module spécifié est introuvable.

Did i miss something ? Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...