다음을 통해 공유


Role-Based 보안 사용 여부 결정

보안 호출 컨텍스트 개체에서 사용할 수 있는 ISecurityCallContext::IsSecurityEnabled 메서드를 사용하여 현재 개체에 대한 보안을 사용할 수 있는지 여부를 확인할 수 있습니다. IsCallerInRole은 보안을 사용하지 않으면 True를 반환하므로 ISecurityCallContext::IsCallerInRole을 사용하여 역할 멤버 자격을 검사 전에 IsSecurityEnabled를 호출해야 합니다.

Microsoft Visual Basic 개발자는 다음 예제와 같이 GetSecurityCallContext 를 호출하여 SecurityCallContext 개체에 대한 참조를 가져온 다음 IsSecurityEnabled를 호출합니다.

Dim objSecCallCtx As SecurityCallContext
Dim boolSecEn As Boolean
Set objSecCallCtx = GetSecurityCallContext()
boolSecEn = objSecCallCtx.IsSecurityEnabled()
 

Microsoft Visual C++ 개발자는 CoGetCallContext를 호출하여 ISecurityCallContext에 대한 포인터를 가져온 다음 IsSecurityEnabled를 호출하여 ISecurityCallContext::IsSecurityEnabled를 호출할 수 있습니다. 간단한 예제는 다음과 같습니다.

ISecurityCallContext* pSecCtx;
VARIANT_BOOL bIsEnabled;

HRESULT hr1 = CoGetCallContext(IID_ISecurityCallContext, (void**)&pSecCtx);
if (FAILED(hr1)) throw(hr1);
if (NULL == pSecCtx) {
    // Display error message.
    return E_FAIL;
}

HRESULT hr2 = pSecCtx->IsSecurityEnabled(&bIsEnabled);
return hr2;

IsSecurityEnabled를 호출하는 기본 방법은 보안 호출 컨텍스트 개체를 사용하는 것이지만 개체 컨텍스트를 통해 IsSecurityEnabled를 호출할 수도 있습니다. 자세한 내용은 ObjectContext 또는 IObjectContext 를 참조하세요.

보안 호출 컨텍스트 정보에 액세스

역할 멤버 자격 확인

프로그래밍 방식 구성 요소 보안