다음을 통해 공유


PolicyLevel.Resolve(Evidence) 메서드

정의

정책 수준에 대한 증명 정보를 기반으로 하여 정책을 확인하고 결과 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

매개 변수

evidence
Evidence

Evidence을 확인하는 데 사용되는 PolicyLevel입니다.

반환

결과 PolicyStatement입니다.

예외

정책 수준에 단독으로 표시된 여러 코드 그룹이 일치하는 경우

evidence 매개 변수가 null인 경우

예제

다음 코드에서는 메서드의 사용을 보여 있습니다 Resolve . 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 PolicyLevel 클래스입니다.

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

설명

Resolve 는 정책 수준에 대한 기본 정책 평가 작업입니다. 증명 정보 집합을 입력으로 지정하면 이 메서드는 루트에서 시작하여 일치하는 대로 작동 중인 코드 그룹의 멤버 자격 조건을 테스트합니다. 일치하는 코드 그룹에서 발생하는 사용 권한의 조합은 반환되는 을 PolicyStatement 생성합니다.

코드에 권한을 부여할 때 보안 정책은 권한에 대한 코드 요청과 함께 적용 가능한 모든 정책 수준에 대해 확인된 정책 문을 사용합니다.

적용 대상