Freigeben über


PolicyLevel.Resolve-Methode

Löst Richtlinien anhand von Beweisen für die Richtlinienebene auf und gibt das resultierende PolicyStatement zurück.

Namespace: System.Security.Policy
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Function Resolve ( _
    evidence As Evidence _
) As PolicyStatement
'Usage
Dim instance As PolicyLevel
Dim evidence As Evidence
Dim returnValue As PolicyStatement

returnValue = instance.Resolve(evidence)
public PolicyStatement Resolve (
    Evidence evidence
)
public:
PolicyStatement^ Resolve (
    Evidence^ evidence
)
public PolicyStatement Resolve (
    Evidence evidence
)
public function Resolve (
    evidence : Evidence
) : PolicyStatement

Parameter

Rückgabewert

Das resultierende PolicyStatement.

Ausnahmen

Ausnahmetyp Bedingung

PolicyException

Die Richtlinienebene enthält mehrere übereinstimmende Codegruppen, die als exklusive gekennzeichnet sind.

ArgumentNullException

Der evidence-Parameter ist NULL (Nothing in Visual Basic).

Hinweise

Resolve ist die grundlegende Operation der Richtlinienauswertung für Richtlinienebenen. Wenn ein Beweissatz als Eingabe vorliegt, überprüft diese Methode Mitgliedschaftsbedingungen von Codegruppen. Die Überprüfung beginnt auf der obersten Ebene und durchläuft die untergeordneten Ebenen entsprechend den Übereinstimmungen. Die aus den übereinstimmenden Codegruppen resultierende Kombination von Berechtigungen erzeugt ein PolicyStatement, das zurückgegeben wird.

Indem Berechtigungen für Code gewährt werden, verwenden Sicherheitsrichtlinien die aufgelösten Richtlinienanweisungen für alle anwendbaren Richtlinienebenen zusammen mit der Codeanforderung für Berechtigungen.

Beispiel

Im folgenden Code wird die Verwendung der Resolve-Methode veranschaulicht. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels für die PolicyLevel-Klasse.

' Demonstrate the use of ResolvePolicy for the supplied evidence and a specified policy level.
Private Overloads Shared Sub CheckEvidence(ByVal pLevel As PolicyLevel, ByVal evidence As Evidence)
    ' Display the code groups to which the evidence belongs.
    Console.WriteLine(ControlChars.Tab + "ResolvePolicy for the given evidence: ")
    Dim codeGroup As IEnumerator = evidence.GetEnumerator()
    While codeGroup.MoveNext()
        Console.WriteLine((ControlChars.Tab + ControlChars.Tab + CType(codeGroup.Current, CodeGroup).Name))
    End While
    Console.WriteLine("The current evidence belongs to the following root CodeGroup:")
    ' pLevel is the current PolicyLevel, evidence is the Evidence to be resolved.
    Dim cg1 As CodeGroup = pLevel.ResolveMatchingCodeGroups(evidence)
    Console.WriteLine((pLevel.Label + " Level"))
    Console.WriteLine((ControlChars.Tab + "Root CodeGroup = " + cg1.Name))

    ' Show how Resolve is used to determine the set of permissions that 
    ' the security system grants to code, based on the evidence.
    ' Show the granted permissions. 
    Console.WriteLine(ControlChars.Lf + "Current permissions granted:")
    Dim pState As PolicyStatement = pLevel.Resolve(evidence)
    Console.WriteLine(pState.ToXml().ToString())

    Return
End Sub 'CheckEvidence
// Demonstrate the use of ResolvePolicy for the supplied evidence and a specified policy level.
private static void CheckEvidence(PolicyLevel pLevel, Evidence evidence)
{
    // Display the code groups to which the evidence belongs.
    Console.WriteLine("\tResolvePolicy for the given evidence: ");
    IEnumerator codeGroup = evidence.GetEnumerator();
    while (codeGroup.MoveNext())
    {
        Console.WriteLine("\t\t" + ((CodeGroup)codeGroup.Current).Name);
    }
    Console.WriteLine("The current evidence belongs to the following root CodeGroup:");
    // pLevel is the current PolicyLevel, evidence is the Evidence to be resolved.
    CodeGroup cg1 = pLevel.ResolveMatchingCodeGroups(evidence);
    Console.WriteLine(pLevel.Label + " Level");
    Console.WriteLine("\tRoot CodeGroup = " + cg1.Name);

    // Show how Resolve is used to determine the set of permissions that 
    // the security system grants to code, based on the evidence.

    // Show the granted permissions. 
    Console.WriteLine("\nCurrent permissions granted:");
    PolicyStatement pState = pLevel.Resolve(evidence);
    Console.WriteLine(pState.ToXml().ToString());

    return;
}
// Demonstrate the use of ResolvePolicy for the supplied evidence and a specified policy level.
void CheckEvidence( PolicyLevel^ pLevel, Evidence^ evidence )
{
   // Display the code groups to which the evidence belongs.
   Console::WriteLine( "\tResolvePolicy for the given evidence: " );
   IEnumerator^ codeGroup = evidence->GetEnumerator();
   while ( codeGroup->MoveNext() )
   {
      Console::WriteLine( "\t\t{0}", (dynamic_cast<CodeGroup^>(codeGroup->Current))->Name );
   }

   Console::WriteLine( "The current evidence belongs to the following root CodeGroup:" );

   // pLevel is the current PolicyLevel, evidence is the Evidence to be resolved.
   CodeGroup^ cg1 = pLevel->ResolveMatchingCodeGroups( evidence );
   Console::WriteLine( "{0} Level", pLevel->Label );
   Console::WriteLine( "\tRoot CodeGroup = {0}", cg1->Name );

   // Show how Resolve is used to determine the set of permissions that 
   // the security system grants to code, based on the evidence.
   // Show the granted permissions. 
   Console::WriteLine( "\nCurrent permissions granted:" );
   PolicyStatement^ pState = pLevel->Resolve( evidence );
   Console::WriteLine( pState->ToXml() );
   return;
}
// Demonstrate the use of ResolvePolicy for the supplied evidence and 
//a specified policy level.
private static void CheckEvidence(PolicyLevel pLevel, Evidence evidence)
{
    // Display the code groups to which the evidence belongs.
    Console.WriteLine("\tResolvePolicy for the given evidence: ");
    IEnumerator codeGroup = evidence.GetEnumerator();
    while (codeGroup.MoveNext()) {
        Console.WriteLine(("\t\t" + ((CodeGroup)
            (codeGroup.get_Current())).get_Name()));
    }

    Console.WriteLine("The current evidence belongs to the "
        + "following root CodeGroup:");

    // pLevel is the current PolicyLevel, evidence is the Evidence
    // to be resolved.
    CodeGroup cg1 = pLevel.ResolveMatchingCodeGroups(evidence);

    Console.WriteLine((pLevel.get_Label() + " Level"));
    Console.WriteLine(("\tRoot CodeGroup = " + cg1.get_Name()));

    // Show how Resolve is used to determine the set of permissions that 
    // the security system grants to code, based on the evidence.
    // Show the granted permissions. 
    Console.WriteLine("\nCurrent permissions granted:");
    PolicyStatement pState = pLevel.Resolve(evidence);
    Console.WriteLine(pState.ToXml().ToString());
    return;
} //CheckEvidence

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

PolicyLevel-Klasse
PolicyLevel-Member
System.Security.Policy-Namespace