PolicyLevel.Resolve(Evidence) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menyelesaikan kebijakan berdasarkan bukti untuk tingkat kebijakan, dan mengembalikan yang dihasilkan 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
Parameter
- evidence
- Evidence
yang Evidence digunakan untuk mengatasi PolicyLevel.
Mengembalikan
Yang dihasilkan PolicyStatement.
Pengecualian
Tingkat kebijakan berisi beberapa grup kode yang cocok yang ditandai sebagai eksklusif.
Parameternya evidence
adalah null
.
Contoh
Kode berikut menunjukkan penggunaan Resolve metode . Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk PolicyLevel kelas .
// 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
Keterangan
Resolve adalah operasi evaluasi kebijakan dasar untuk tingkat kebijakan. Mengingat seperangkat bukti sebagai input, metode ini menguji kondisi keanggotaan grup kode mulai dari akar dan bekerja seperti yang dicocokkan. Kombinasi izin yang dihasilkan dari grup kode yang cocok menghasilkan PolicyStatement yang dikembalikan.
Dalam memberikan izin ke kode, kebijakan keamanan menggunakan pernyataan kebijakan yang diselesaikan untuk semua tingkat kebijakan yang berlaku, bersama dengan permintaan kode untuk izin.