I stitched a couple of scripts together for you. It's not the same output you
listed below but can be modified and will produce this:
AUTHORS of http://server/workspace/Documents/Folder1
CPR\wei0051
CPR\mci0063
CPR\new0050
COORDINATORS of http://server/workspace/Documents/Folder2
CPR\sim0099
CPR\bob0011
CPR\chi0028
Here's the code:
' ListAuthors.vbs
' List all authors and permissions for a location
' Bil Simser 09/09/2003 v1.0 Based on code by Andy Ball
Set objPKMWrk = CreateObject("CDO.KnowledgeWorkspace")
Dim objPKMWrk ' CDO.KnowledgeWorkspace
Dim objRS ' ADODB.RecordSet
' get the args
Set WshShell = Wscript.CreateObject("Wscript.Shell")
set oArgs=Wscript.Arguments
' get Servername passed in otherwise use local machine
if oArgs.Count <> 1 Then
Wscript.Echo "Usage : CSCRIPT listfiles.vbs http://server/workspace/Documents"
WScript.Quit
Else
kWorkspaceURL = oArgs.Item(0)
End If
' Connect to a workspace in read only mode.
objPKMWrk.DataSource.Open kWorkspaceURL, , adModeRead
' Get the folders inside the workspace.
Set objRS = objPKMWrk.Subfolders
' Call sub to enumerate subfolders of workspace.
EnumRS objRS
'
' EnumRS(objRS)
' objRS is a ADO RecordSet containing the subfolders within a folder or
workspace
' usually obtained from the .SubFolders property off a KnowledgeFolder or
' KnowledgeWorkspace object.
'
' Walks thru a recordset until EOF and then calls itself to enumerate any object
' which contains more folders.
'
Sub EnumRS(objRS)
Dim objPKMFld ' CDO.KnowledgeFolder
Dim objTmpRS ' ADODB.RecordSet
Dim objFolder
Dim User
Dim ArrayItemCount
' Loop until end of RecordSet
Do While objRS.EOF <> True
ShowFolderPermissionsAll objRS("DAV:href")
' If the folder contains subfolders then enumerate them too
If CBool(objRS("DAV:iscollection")) Then
' Create a CDO.KnowledgeFolder object and point it to
' the folder in read only mode.
Set objPKMFld = CreateObject("CDO.KnowledgeFolder")
objPKMFld.DataSource.Open objRS("DAV:href"), , adModeRead
' Get the folders inside the folder.
Set objTmpRS = objPKMFld.Subfolders
' Recursively call sub to enumerate folders within folders.
EnumRS objTmpRS
End If
' Move to next record within RecordSet
objRS.MoveNext
Loop
End Sub
' Sub ShowFolderPermission
' Shows permissions on the relevant folder
Sub ShowFolderPermissions (FolderPath, Permission)
Dim arPermissions ' Array to store current permissions
Dim oFolder ' folder object
Dim User ' item used in FOR EACH in array
Dim ArrayItemCount
' Create object
set oFolder = CreateObject("CDO.KnowledgeFolder")
' Open the folder
oFolder.DataSource.Open FolderPath
' Return the relevant array depending on the type of user
Select Case UCASE(Permission)
Case "READER" arPermissions = oFolder.Readers
Case "COORDINATOR" arPermissions = oFolder.CoOrdinators
Case "AUTHOR" arPermissions = oFolder.Authors
' trap dodgy permission. Would be cool if could retrive valid permissions as
this is likely to change between versions
Case Else WScript.Echo Permission & " is not valid. Should be READER, AUTHOR
or Coordinator"
Exit Sub
End Select
' Get the number of items in the array
ArrayItemCount = UBound(arPermissions) + 1
' ie if no (say) readers print message
if ArrayItemCount = 0 Then
WScript.Echo "No " & Permission & " Permissions on " & FolderPath
' Otherwise roll through printing permissions
Else
Wscript.Echo Permission & "S of " & FolderPath
For Each User in arPermissions
Wscript.Echo vbTAB & User
Next
End If
set oFolder = Nothing
End Sub
' Show all permissions
' Procedure ShowFolderPermissionsAll
Sub ShowFolderPermissionsAll(FolderPath)
ShowFolderPermissions FolderPath, "READER"
ShowFolderPermissions FolderPath, "AUTHOR"
ShowFolderPermissions FolderPath, "COORDINATOR"
End Sub