PolicyLevel.Resolve(Evidence) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Löser principen baserat på bevis för principnivån och returnerar den resulterande PolicyStatement.
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
Parametrar
- evidence
- Evidence
Används Evidence för att lösa PolicyLevel.
Returer
Den resulterande PolicyStatement.
Undantag
Principnivån innehåller flera matchande kodgrupper som markerats som exklusiva.
Parametern evidence är null.
Exempel
Följande kod visar användningen av Resolve metoden. Det här kodexemplet är en del av ett större exempel för PolicyLevel klassen.
// 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
Kommentarer
Resolve är den grundläggande principutvärderingsåtgärden för principnivåer. Med tanke på en uppsättning bevis som indata testar den här metoden medlemskapsvillkor för kodgrupper som börjar vid roten och arbetar nedåt enligt matchning. Kombinationen av behörigheter som följer av matchande kodgrupper genererar en PolicyStatement som returneras.
Vid beviljande av behörigheter till kod använder säkerhetsprincipen de lösta principinstruktionerna för alla tillämpliga principnivåer, tillsammans med kodbegäran för behörigheter.