I have several COM+ applications that make use of role based security. During any troubleshooting, manually checking each component to ensure that both the 'Enforce component level access checks' and 'Roles explicity set for selected item(s)' boxes are checked can be a pain.
Half the problem has been addressed with the script below (Enforce component level access checks), but I am struggling to find a way to programatically determine if any roles that are assigned to the component also have their checkbox enabled.
Any help much appreciated!
Clear-Host;
$comAdmin = New-Object -com ("COMAdmin.COMAdminCatalog.1");
$applications = $comAdmin.GetCollection("Applications") ;
$applications.Populate() ;
$appfilter = "ABC";
foreach ($application in $applications){
if($application.name.substring(0,3) -eq $appfilter){
try{
$components = $applications.GetCollection("Components",$application.key)
$components.Populate()
foreach ($component in $components){
$componentName = $component.Name;
Write-Host $componentName;
$accesschecks = $component.Value("ComponentAccessChecksEnabled");
Write-Host "Access Checks Enabled: " -NoNewLine;
Switch ($accesschecks){
$true{Write-Host $accesschecks -ForegroundColor Green}
$false{Write-Host $accesschecks -ForegroundColor red -BackgroundColor white}
}
$roles = $applications.GetCollection("Roles",$application.key) ;
$roles.Populate();
$rolename = $roles.Item(0).Name;
#$roleenabled = !!???!!
Write-Host "Role: $rolename Enabled: " -NoNewLine;
Switch ($roleenabled){
$true{Write-Host $roleenabled -ForegroundColor Green}
$false{Write-Host $roleenabled -ForegroundColor red -BackgroundColor white}
}
Write-Host;
}
}
catch{}
}
Write-Host "-------------------------------------";
}