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.

Listing Directory Shares with Permissions

Keywords: 	  wntAccessList

Question:

what i need to do is make a script that can list all the shares on a server with who has permissions to that share,here what i have so far is(NT4 domain)...
AddExtender("WWWNT34i.DLL")
servern = AskLine("Server Name", "Name of server, no \\", "")
if FileExist("buff1.tmp")
FileDelete("buff1.tmp")
endif

localgroups=wntListGroups("\\%servern%",@LOCALGROUP)
ShareList = wntShareList("\\%servern%", 1 , 0)
ShareCount = ItemCount(ShareList, @TAB)
GroupCount = ItemCount(LocalGroups,@TAB) 

For Count = 1 to ShareCount
While Count < ShareCount
share = ItemExtract( Count , ShareList, @TAB) 
ShareAccess = wntAccessList("\\%servern%", share, 100, 0)
ShareAccess=StrReplace(ShareAccess, @tab , ",")
handle = FileOpen("buff1.tmp", "APPEND")
FileWrite(handle, "%Share% - %ShareAccess% ")
Count = Count + 1
FileClose(handle)
EndWhile 
but all this returns is ,
Share name - joe, bob, admins, everyone
Share name - user1, user2
i need to know EVERYTHING including the sub directory's, what i would like is something more like this...
\Work - Everyone
\Work\Users - Everyone
\Work\Users\Bob - Bob, Domain Admins
etc.
I know this will make a VERY long list, but thats what i need :-)

...and the variable i put in "localgroups"? well in the end i will compare the share list with the list of localgroups so i can find what local groups are using what shares and convert them over to a global group.

So basically, How do i traverse the sub directory's?

Answer:

Reference the share a UNC spec and specify object type 300.
wntAccessList("\\MyServer","\\MyServer\MyShare",300,1)
Do that instead of the following:
wntAccessList("\\MyServer","MyShare",100,1)
Object type 100 is a share itself, not the underlying NTFS volume with its associated security settings. Object type 300 specifically refers to an NTFS volume, either a folder or a file on the volume to be more exact.
Article ID:   W14883
File Created: 2001:11:08:12:40:48
Last Updated: 2001:11:08:12:40:48