'--------------------------------------------
' $Workfile: AccessRights.vbs$
' $Author: Steven Lange$
' $Date: 8/4/2000 6:50:37 AM$
' $Revision: 11$
' Requirements:
' - StarGateSDK
' - Windows Scripting Host
'--------------------------------------------
Dim strServer, nPort, strFileName
Dim strUser, strPassword
' ~~~ Modify these values for your needs ~~~ '
strAddress = "myServerName"
nPort = 49201
strUser = "Administrator"
strPassword = "MyAdminPassword"
strFileName = "AccessRights.txt"
' ~~~ Don't modify below here! ~~~ '
' Check for command-line parameters
' server address
If (WScript.Arguments.Count > 0) Then
strAddress = WScript.Arguments(0)
End If
' server port
If (WScript.Arguments.Count > 1) Then
nPort = CInt(WScript.Arguments(1))
End If
' user name
If (WScript.Arguments.Count > 2) Then
strUser = WScript.Arguments(2)
End If
' password
If (WScript.Arguments.Count > 3) Then
strPassword = WScript.Arguments(3)
End If
'filename
If (WScript.Arguments.Count > 4) Then
strFileName = WScript.Arguments()
End If
' Grant or Deny?
Function GD(ByVal granted)
if Granted = True then
GD = "Grant"
else
GD = "Deny"
end if
End Function
' Get Name of User or Group.
Function getName(ByVal id, ByVal isGroup)
if isGroup = True then
getName = StServer.Administration.findGroupAccount(id).Name
else
getName = StServer.Administration.findUserAccount(id).Name
end if
End Function
' Write the access rights entries.
Sub WriteACL(ByVal list, ByVal p,ByVal aType)
dim e
For e = 0 to list.Count-1
FileObj.WriteLine(Space(8) & e+1 & ". " & GD(list(e).Granted) & " - " & getName(list(e).id,list(e).GroupID))
Select Case aType '0=server,1=project,2=view,3=folder
Case 0 ' server
PServer list(e),p
Case 1 ' project
PGeneric list(e),p
PItem list(e),p
Case 2 ' view
PGeneric list(e),p
PItem list(e),p
Case Else ' other
PGeneric list(e),p
PItem list(e),p
End Select
next
End Sub
' Write the permissions
Sub PGeneric(ByVal entry,ByVal p)
if entry.hasPermission(p.GENERIC_AQUIRE_OWNERSHIP) then
FileObj.Write(Space(13) & "- Acquire Object Ownership" & VbCrLf)
end if
if entry.hasPermission(p.GENERIC_CHANGE_ACCESS_RIGHTS) then
FileObj.Write(Space(13) & "- Modify Security Settings" & VbCrLf)
end if
if entry.hasPermission(p.GENERIC_CREATE_NEW_OBJECT) then
FileObj.Write(Space(13) & "- Create New Object" & VbCrLf)
end if
if entry.hasPermission(p.GENERIC_DELETE_OBJECT) then
FileObj.Write(Space(13) & "- Delete Object" & VbCrLf)
end if
if entry.hasPermission(p.GENERIC_MODIFY_OBJECT) then
FileObj.Write(Space(13) & "- Modify Object Properties" & VbCrLf)
end if
if entry.hasPermission(p.GENERIC_PURGE_OBJECT) then
FileObj.Write(Space(13) & "- Purge Object" & VbCrLf)
end if
if entry.hasPermission(p.GENERIC_SEE_OBJECT) then
FileObj.Write(Space(13) & "- See Object and its Properties" & VbCrLf)
end if
End Sub
Sub PServer(ByVal entry,ByVal p)
if entry.hasPermission(p.SERVER_ADMIN_REMOTELY) then
FileObj.Write(Space(13) & "- Remotely Administer Server" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_ADMIN_USER_ACCOUNTS) then
FileObj.Write(Space(13) & "- Administer User Accounts" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_CREATE_PROJECT) then
FileObj.Write(Space(13) & "- Create New Project" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_MODIFY_CONFIGURATION) then
FileObj.Write(Space(13) & "- Modify Server Configuration" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_MODIFY_SCHEMA) then
FileObj.Write(Space(13) & "- Modify Database Schema" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_MODIFY_SYSTEM_POLICY) then
FileObj.Write(Space(13) & "- Modify System Policy" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_VIEW_CONFIGURATION) then
FileObj.Write(Space(13) & "- View Server Configuration" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_VIEW_DIAGNOSTICS) then
FileObj.Write(Space(13) & "- View Server Diagnostics" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_VIEW_LOG) then
FileObj.Write(Space(13) & "- View Server Log" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_VIEW_SECURITY_LOG) then
FileObj.Write(Space(13) & "- View Server Security Log" & VbCrLf)
end if
if entry.hasPermission(p.SERVER_VIEW_SYSTEM_POLICY) then
FileObj.Write(Space(13) & "- View System Policy" & VbCrLf)
end if
End Sub
Sub PView(ByVal entry,ByVal p)
if entry.hasPermission(p.VIEW_CREATE_LABEL) then
FileObj.Write(Space(13) & "- Create Label" & VbCrLf)
end if
if entry.hasPermission(p.VIEW_DEFINE_PROMOTION_MODEL) then
FileObj.Write(Space(13) & "- Define Promotion Model" & VbCrLf)
end if
if entry.hasPermission(p.VIEW_DELETE_LABEL) then
FileObj.Write(Space(13) & "- Delete Label" & VbCrLf)
end if
if entry.hasPermission(p.VIEW_EDIT_LABEL) then
FileObj.Write(Space(13) & "- Modify Label" & VbCrLf)
end if
if entry.hasPermission(p.VIEW_MODIFY_PROMOTION_STATUS) then
FileObj.Write(Space(13) & "- Modify Promotion Status" & VbCrLf)
end if
End Sub
Sub PItem(ByVal entry,ByVal p)
if entry.hasPermission(p.FILE_CHECKIN) then
FileObj.Write(Space(13) & "- Check In File" & VbCrLf)
end if
if entry.hasPermission(p.FILE_CHECKOUT) then
FileObj.Write(Space(13) & "- Check Out File" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_ADD_LABEL) then
FileObj.Write(Space(13) & "- Create New Label" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_ADJUST_LABEL) then
FileObj.Write(Space(13) & "- Adjust Label" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_BREAK_EXCLUSIVE_LOCK) then
FileObj.Write(Space(13) & "- Break Exclusive Lock" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_CREATE_LINKS) then
FileObj.Write(Space(13) & "- Create Links" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_DELETE_LINKS) then
FileObj.Write(Space(13) & "- Delete Links" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_DETACH_LABEL) then
FileObj.Write(Space(13) & "- Detach Label" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_LOCK_EXCLUSIVELY) then
FileObj.Write(Space(13) & "- Set Exclusive Lock" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_MODIFY_BEHAVIOR) then
FileObj.Write(Space(13) & "- Modify Item Behavior" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_MODIFY_LINKS) then
FileObj.Write(Space(13) & "- Modify Links" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_PERFORM_MAINTENANCE) then
FileObj.Write(Space(13) & "- Perform Item Maintenance" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_SEE_HISTORY) then
FileObj.Write(Space(13) & "- See History" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_SEE_LINKS) then
FileObj.Write(Space(13) & "- See Links" & VbCrLf)
end if
if entry.hasPermission(p.ITEM_SHARE_MOVE) then
FileObj.Write(Space(13) & "- Share/Move Items" & VbCrLf)
end if
End Sub
' Write a string of characters.
Sub FillChars(ByVal ch,ByVal length)
dim x
for x = 1 to length
FileObj.Write(ch)
next
FileObj.Write(vbCrLf)
End Sub
' Write the report header.
Sub WriteHeader()
FillChars "=",70
FileObj.WriteLine("STARTEAM ACCESS RIGHTS REPORT")
FillChars "=",70
FileObj.WriteBlankLines(1)
FileObj.WriteLine("KEY: Project::ViewPath::FolderPath" & vbCrLf)
FileObj.WriteLine("** This report was run against StarTeam Server: " & strAddress & ":" & nPort & vbCrLf)
End Sub
' Write the report footer.
Sub WriteFooter()
FillChars "-",70
FileObj.WriteLine("END REPORT" & Space(60-Len(Now())) & Now())
FillChars "-",70
End Sub
Function CheckforACL(myACL)
if UCase(TypeName(myACL)) <> "NOTHING" then
CheckforACL = True
else
CheckforACL = False
end if
End Function
' Enumerate through the projects.
Sub EnumProjects(ByVal StServer)
dim proj
for each proj in StServer.Projects
found = false
if CheckforACL(proj.acl) = true then
if found = false then
FileObj.WriteLine(proj.Name)
found = true
end if
FileObj.WriteLine(Space(5) & "*" & cons(0))
WriteACL proj.acl,p,1
end if
for c = 1 to 6
if CheckforACL(proj.getContainerLevelACL(cons(c))) = true then
if found = false then
FileObj.WriteLine(proj.Name)
found = true
end if
FileObj.WriteLine(Space(5) & "*" & cons(c) & "s:")
WriteACL proj.getContainerLevelACL(cons(c)),p,c+1
end if
next
EnumViews proj
FileObj.WriteBlankLines(1)
next
End Sub