AsBuiltReport / AsBuiltReport.VMware.vSphere

Repository for AsBuiltReport VMware vSphere module
https://www.asbuiltreport.com
MIT License
112 stars 39 forks source link

vCenter user privileges doesn't handle groups #102

Open nathcoad opened 2 years ago

nathcoad commented 2 years ago

Describe the bug The As Built Report for vSphere is unable to determine privileges of user running the report if they receive privileges via a group (eg Active Directory group) rather than directly assigned.

To Reproduce Steps to reproduce the behavior:

  1. Run the As Built Report against a vCenter
  2. Output includes messages such as "Insufficient user privileges to report vCenter Server licensing"

Expected behavior As built report should be aware of privileges allocated via AD group.

Screenshots If applicable, add screenshots to help explain your problem.

System (please provide the following information about the system from which you are trying to generate a report):

Additional context Code in Invoke-AsBuiltReport.VMware.vSphere.ps1 beginning line 50 can be changed to instead check the effective user privileges rather than looking for directly assigned role. For example, to get a list of the effective privileges at the top level in vCenter, you could use code like this. Then you can compare that list against the expected required privilege for a given piece of information (eg Global.Licenses for the ESXi licenses"

$AuthMgr = Get-View $($vCenter.ExtensionData.Content.AuthorizationManager)
$Privileges = $authMgr.FetchUserPrivilegeOnEntities("Folder-group-d1", $vCenter.User)