Visual C++ .NET/Security/SecurityManager
Iterate backwards removing all instances of "ReadOnly Secure Group"
#include "stdafx.h"
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::Security::Policy;
void main()
{
CodeGroup^ machine;
System::Collections::IEnumerator^ ph = SecurityManager::PolicyHierarchy();
for (int i = machine->Children->Count - 1; i >= 0; i--)
{
if(((CodeGroup^)machine->Children[i])->Name == "ReadOnly Secure Group")
{
machine->RemoveChild(((CodeGroup^)machine->Children[i]));
}
}
SecurityManager::SavePolicy();
}
Iterate through policy hierarchy to get Machine Code group
#include "stdafx.h"
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::Security::Policy;
void main()
{
CodeGroup^ machine;
System::Collections::IEnumerator^ ph = SecurityManager::PolicyHierarchy();
while( ph->MoveNext() )
{
PolicyLevel^ machinePolicyLevel = (PolicyLevel^)ph->Current;
if (machinePolicyLevel->Label == "Machine")
{
machine = machinePolicyLevel->RootCodeGroup;
break;
}
}
SecurityManager::SavePolicy();
}