Share and NTFS Permissions 
Author Message
 Share and NTFS Permissions

I am trying to write a script to find out which rights users and groups have
on a networkshare. And I want to know this on share level and NTFS level. I
wrote a script that does something like this, but it gives back only the
rights of one user/group which is not identified and it are only the rights
for the share. I can find lots of things about how to set permissions, but
nothing about reading the permissions. Can someone help me or point me in
the right direction?

This is the code I have made (pretty simple though):

On Error Resume Next
 strComputer = "."
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objTextFile = objFSO.CreateTextFile("Permissions.txt", True)
 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 Set colItems = objWMIService.ExecQuery("Select * from Win32_Share",,48)
 For Each objItem in colItems
    ObjTextFile.WriteLine "Path: " & objItem.Path
    ObjTextFile.WriteLine "Permissions:"
    calculate(objItem.GetAccessMask)
 next

sub calculate(iPerm)
 if iPerm >= 1048576 then
  ObjTextFile.WriteLine vbtab & "SYNCHRONIZE"
  calculate(iPerm - 1048576)
 elseif iPerm >= 524288 then
  ObjTextFile.WriteLine vbtab & "WRITE_OWNER"
  calculate(iPerm - 524288)
 elseif iPerm >= 262144 then
  ObjTextFile.WriteLine vbtab & "WRITE_DAC"
  calculate(iPerm - 262144)
 elseif iPerm >= 131072 then
  ObjTextFile.WriteLine vbtab & "READ_CONTROL"
  calculate(iPerm - 131072)
 elseif iPerm >= 65536 then
  ObjTextFile.WriteLine vbtab & "DELETE"
  calculate(iPerm - 65536)
 elseif iPerm >= 256 then
  ObjTextFile.WriteLine vbtab & "FILE_WRITE_ATTRIBUTES"
  calculate(iPerm - 256)
 elseif iPerm >= 128 then
  ObjTextFile.WriteLine vbtab & "FILE_READ_ATTRIBUTES"
  calculate(iPerm - 128)
 elseif iPerm >= 64 then
  ObjTextFile.WriteLine vbtab & "FILE_DELETE_CHILD"
  calculate(iPerm - 64)
 elseif iPerm >= 32 then
  ObjTextFile.WriteLine vbtab & "FILE_TRAVERSE"
  calculate(iPerm - 32)
 elseif iPerm >= 16 then
  ObjTextFile.WriteLine vbtab & "FILE_WRITE_EA"
  calculate(iPerm - 16)
 elseif iPerm >= 8 then
  ObjTextFile.WriteLine vbtab & "FILE_READ_EA"
  calculate(iPerm - 8)
 elseif iPerm >= 4 then
  ObjTextFile.WriteLine vbtab & "FILE_ADD_SUBDIRECTORY"
  calculate(iPerm - 4)
 elseif iPerm >= 2 then
  ObjTextFile.WriteLine vbtab & "FILE_ADD_FILE"
  calculate(iPerm - 2)
 elseif iPerm >= 1 then
  ObjTextFile.WriteLine vbtab & "FILE_LIST_DIRECTORY"
  calculate(iPerm - 1)
 end if
end sub



Mon, 05 Dec 2005 16:25:50 GMT  
 Share and NTFS Permissions
This script doesn't work when "Everyone" has no authorization!


Quote:
> I am trying to write a script to find out which rights users and groups
have
> on a networkshare. And I want to know this on share level and NTFS level.
I
> wrote a script that does something like this, but it gives back only the
> rights of one user/group which is not identified and it are only the
rights
> for the share. I can find lots of things about how to set permissions, but
> nothing about reading the permissions. Can someone help me or point me in
> the right direction?

> This is the code I have made (pretty simple though):

> On Error Resume Next
>  strComputer = "."
>  Set objFSO = CreateObject("Scripting.FileSystemObject")
>  Set objTextFile = objFSO.CreateTextFile("Permissions.txt", True)
>  Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
>  Set colItems = objWMIService.ExecQuery("Select * from Win32_Share",,48)
>  For Each objItem in colItems
>     ObjTextFile.WriteLine "Path: " & objItem.Path
>     ObjTextFile.WriteLine "Permissions:"
>     calculate(objItem.GetAccessMask)
>  next

> sub calculate(iPerm)
>  if iPerm >= 1048576 then
>   ObjTextFile.WriteLine vbtab & "SYNCHRONIZE"
>   calculate(iPerm - 1048576)
>  elseif iPerm >= 524288 then
>   ObjTextFile.WriteLine vbtab & "WRITE_OWNER"
>   calculate(iPerm - 524288)
>  elseif iPerm >= 262144 then
>   ObjTextFile.WriteLine vbtab & "WRITE_DAC"
>   calculate(iPerm - 262144)
>  elseif iPerm >= 131072 then
>   ObjTextFile.WriteLine vbtab & "READ_CONTROL"
>   calculate(iPerm - 131072)
>  elseif iPerm >= 65536 then
>   ObjTextFile.WriteLine vbtab & "DELETE"
>   calculate(iPerm - 65536)
>  elseif iPerm >= 256 then
>   ObjTextFile.WriteLine vbtab & "FILE_WRITE_ATTRIBUTES"
>   calculate(iPerm - 256)
>  elseif iPerm >= 128 then
>   ObjTextFile.WriteLine vbtab & "FILE_READ_ATTRIBUTES"
>   calculate(iPerm - 128)
>  elseif iPerm >= 64 then
>   ObjTextFile.WriteLine vbtab & "FILE_DELETE_CHILD"
>   calculate(iPerm - 64)
>  elseif iPerm >= 32 then
>   ObjTextFile.WriteLine vbtab & "FILE_TRAVERSE"
>   calculate(iPerm - 32)
>  elseif iPerm >= 16 then
>   ObjTextFile.WriteLine vbtab & "FILE_WRITE_EA"
>   calculate(iPerm - 16)
>  elseif iPerm >= 8 then
>   ObjTextFile.WriteLine vbtab & "FILE_READ_EA"
>   calculate(iPerm - 8)
>  elseif iPerm >= 4 then
>   ObjTextFile.WriteLine vbtab & "FILE_ADD_SUBDIRECTORY"
>   calculate(iPerm - 4)
>  elseif iPerm >= 2 then
>   ObjTextFile.WriteLine vbtab & "FILE_ADD_FILE"
>   calculate(iPerm - 2)
>  elseif iPerm >= 1 then
>   ObjTextFile.WriteLine vbtab & "FILE_LIST_DIRECTORY"
>   calculate(iPerm - 1)
>  end if
> end sub



Tue, 06 Dec 2005 19:41:16 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Reading Share and NTFS Permissions

2. share and ntfs permissions

3. File Sharing and NTFS Permissions

4. NTFS and Share Permissions

5. VbScript DeleteFile method failing due to permissions on W2KS NTFS with Everyone Full permissions

6. enumerating shares and share permissions with vbscript

7. share permissions and enumerating shares

8. List shares and share permissions?

9. Creating a share with share permissions

10. Using WMI and VBS to share folders and set share / NTFS permissions....

11. Ntfs Security And making shares

12. NTFS File Permissions

 

 
Powered by phpBB® Forum Software