WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

wNT
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Obtain Share Permissions


The following script demonstrates iterating thru the list of Security Principals [e.g. users & groups] that have assigned permissions on a share, then it iterates thru the ACEs assigned to each security principal. The results are copied to the clipboard when the script finishes, and you can then paste them into Notepad or any other text processing application to view them.

You'll have to modify the script to suit your own purposes in terms of determining if specific rights have been granted to any particular user or group. Read the help topic for wntAccessAdd(), as it fully explains in a significant amount of detail how ACEs are formatted and what the meaning is for each of the 3 components that an ACE is composed of. For your needs, simply comparing the entire ACE to the values of one of the pre-defined access strings might work just fine. Or, you can manually set the desired permissions that you're testing for on a share, use this script to dump them out, and then write your test & compare code to work with the values obtained from this script.

; DumpShareDACL.wbt
; 32-bit
;
; Refer to the help topic for wntAccessAdd() to understand what the different parts of an ACE actually mean.
; Please note that the assigned access-mask values for ACEs may vary from one version of Windows to another,
; but still have the same effective rights assignments.  I know this is confusing, but it's just the way things
; are in terms of how security works on Windows.  Fortunately, shares have some of the most basic security.
;
; This script has no error handling in it, and it does very little to "scrub" the user-provided input data.


AddExtender('wwwnt34i.dll')

Title01 = 'Dump Share DACL'

sServer = AskLine(Title01,'Enter server name','',0)

sServer = StrReplace(sServer,'\','')

sShare = AskLine(Title01,'Enter share name','',0)

sShare = StrReplace(sShare,'\','')

sPermissions = ''


sIDList = wntAccessList('\\' : sServer,sShare,100,1)

nIDCount = ItemCount(sIDList,@TAB)

For nIDIndex = 1 To nIDCount
  sID = ItemExtract(nIDIndex,sIDList,@TAB)
  sPermissions = sPermissions : sID : @CRLF
  sACEList = wntAccessGet('\\' : sServer,sShare,sID,100,0)
  nACECount = ItemCount(sACEList,'|')
  For nACEIndex = 1 To nACECount
    sACE = ItemExtract(nACEIndex,sACEList,'|')
    sPermissions = sPermissions : @TAB : sACE : @CRLF
  Next
Next

ClipPut(sPermissions)

Message(Title01,'Results copied to the clipboard.')


Exit

Article ID:   W17998
Filename:   Obtain Share Permissions.txt
File Created: 2008:11:25:13:54:12
Last Updated: 2008:11:25:13:54:12