我有几个使用基于角色的安全性的 COM+ 应用程序。在任何故障排除期间,手动检查每个组件以确保选中“强制组件级别访问检查”和“为选定项目设置的角色明确设置”框可能会很痛苦。
下面的脚本已经解决了一半的问题(强制执行组件级别访问检查),但我正在努力寻找一种方法来以编程方式确定分配给组件的任何角色是否也启用了它们的复选框。
非常感谢任何帮助!
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 "-------------------------------------";
}