PolicyLevel.Resolve(Evidence) Metoda

Definicja

Rozwiązuje zasady na podstawie dowodów na poziomie zasad i zwraca wynikowy PolicyStatementelement .

public:
 System::Security::Policy::PolicyStatement ^ Resolve(System::Security::Policy::Evidence ^ evidence);
public System.Security.Policy.PolicyStatement Resolve (System.Security.Policy.Evidence evidence);
member this.Resolve : System.Security.Policy.Evidence -> System.Security.Policy.PolicyStatement
Public Function Resolve (evidence As Evidence) As PolicyStatement

Parametry

evidence
Evidence

Element Evidence używany do rozpoznawania .PolicyLevel

Zwraca

PolicyStatementWynikowy element .

Wyjątki

Poziom zasad zawiera wiele pasujących grup kodu oznaczonych jako wykluczające.

Parametr evidence ma wartość null.

Przykłady

Poniższy kod przedstawia użycie Resolve metody . Ten przykład kodu jest częścią większego przykładu udostępnionego PolicyLevel dla klasy .

// 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.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.
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

Uwagi

Resolve jest podstawową operacją oceny zasad dla poziomów zasad. Biorąc pod uwagę zestaw dowodów jako dane wejściowe, ta metoda testuje warunki członkostwa grup kodu, zaczynając od katalogu głównego i pracując w dół zgodnie z dopasowaniem. Kombinacja uprawnień wynikających z pasujących grup kodu generuje zwrócony PolicyStatement element.

W przypadku udzielania uprawnień do kodu zasady zabezpieczeń używają rozwiązanych instrukcji zasad dla wszystkich odpowiednich poziomów zasad wraz z żądaniem kodu uprawnień.

Dotyczy