다음을 통해 공유


WinBioRemoveCredential 함수(winbio.h)

지정된 사용자의 생체 인식 로그온 자격 증명을 삭제합니다. Windows 10 빌드 1607부터 이 함수를 모바일 이미지와 함께 사용할 수 있습니다.

문법

HRESULT WinBioRemoveCredential(
  [in] WINBIO_IDENTITY        Identity,
  [in] WINBIO_CREDENTIAL_TYPE Type
);

매개 변수

[in] Identity

로그온 자격 증명이 제거될 사용자 계정의 SID를 포함하는 WINBIO_IDENTITY 구조체입니다.

[in] Type

자격 증명 형식을 지정하는 WINBIO_CREDENTIAL_TYPE 값입니다. 다음 값 중 하나일 수 있습니다.

가치 Meaning
WINBIO_CREDENTIAL_PASSWORD
암호 기반 자격 증명이 삭제됩니다.
WINBIO_CREDENTIAL_ALL
사용자의 모든 로그온 자격 증명이 삭제됩니다.

반환 값

함수가 성공하면 S_OK 반환합니다. 함수가 실패하면 오류를 나타내는 HRESULT 값을 반환합니다. 가능한 값은 다음 표에 있는 값을 포함하지만 제한되지는 않습니다. 일반적인 오류 코드 목록은 Common HRESULT 값을 참조하세요.

반환 코드 Description
E_ACCESSDENIED
호출자에게 자격 증명을 삭제할 수 있는 권한이 없습니다.
WINBIO_E_CRED_PROV_NO_CREDENTIAL
지정된 ID가 없거나 자격 증명 저장소에 관련 레코드가 없습니다.

비고

상승된 권한이 없는 사용자는 자신의 자격 증명만 삭제할 수 있습니다. 관리자 권한 사용자는 모든 사용자 계정에 대한 자격 증명을 제거할 수 있습니다. 자격 증명을 삭제해도 해당 사용자의 생체 인식 등록에는 영향을 주지 않습니다. 생체 인식 자격 증명을 삭제해도 사용자가 암호를 사용하여 로그온할 수 없습니다. 중간 이상의 무결성 프로세스만 자격 증명을 삭제할 수 있습니다. 낮은 무결성 프로세스에서 자격 증명을 삭제하려고 하면 함수는 E_ACCESSDENIED 반환합니다.

예시

다음 함수는 WinBioRemoveCredential 을 호출하여 특정 사용자에 대한 자격 증명을 제거하는 방법을 보여줍니다. 도우미 함수 GetCurrentUserIdentity도 포함됩니다. Winbio.lib 정적 라이브러리에 연결하고 다음 헤더 파일을 포함합니다.

  • Windows.h
  • Stdio.h
  • Conio.h
  • Winbio.h
HRESULT RemoveCredential()
{
    HRESULT hr = S_OK;
    WINBIO_IDENTITY identity;

    // Find the identity of the user.
    wprintf_s(L"\n Finding user identity.\n");
    hr = GetCurrentUserIdentity( &identity );
    if (FAILED(hr))
    {
        wprintf(L"\n User identity not found. hr = 0x%x\n", hr);
        goto e_Exit;
    }

    // Remove the user credentials.
    hr = WinBioRemoveCredential(identity, WINBIO_CREDENTIAL_PASSWORD);
    if (FAILED(hr)) 
    {
        wprintf(L"\n WinBioRemoveCredential failed. hr = 0x%x\n", hr);
        goto e_Exit;
    }

    wprintf_s(L"\n User credentials successfully removed.\n");

e_Exit:

    wprintf_s(L"\n Press any key to exit...");
    _getch();

    return hr;
}

//------------------------------------------------------------------------
// The following function retrieves the identity of the current user.
// This is a helper function and is not part of the Windows Biometric
// Framework API.
//
HRESULT GetCurrentUserIdentity(__inout PWINBIO_IDENTITY Identity)
{
    // Declare variables.
    HRESULT hr = S_OK;
    HANDLE tokenHandle = NULL;
    DWORD bytesReturned = 0;
    struct{
        TOKEN_USER tokenUser;
        BYTE buffer[SECURITY_MAX_SID_SIZE];
    } tokenInfoBuffer;

    // Zero the input identity and specify the type.
    ZeroMemory( Identity, sizeof(WINBIO_IDENTITY));
    Identity->Type = WINBIO_ID_TYPE_NULL;

    // Open the access token associated with the
    // current process
    if (!OpenProcessToken(
            GetCurrentProcess(),            // Process handle
            TOKEN_READ,                     // Read access only
            &tokenHandle))                  // Access token handle
    {
        DWORD win32Status = GetLastError();
        wprintf_s(L"Cannot open token handle: %d\n", win32Status);
        hr = HRESULT_FROM_WIN32(win32Status);
        goto e_Exit;
    }

    // Zero the tokenInfoBuffer structure.
    ZeroMemory(&tokenInfoBuffer, sizeof(tokenInfoBuffer));

    // Retrieve information about the access token. In this case,
    // retrieve a SID.
    if (!GetTokenInformation(
            tokenHandle,                    // Access token handle
            TokenUser,                      // User for the token
            &tokenInfoBuffer.tokenUser,     // Buffer to fill
            sizeof(tokenInfoBuffer),        // Size of the buffer
            &bytesReturned))                // Size needed
    {
        DWORD win32Status = GetLastError();
        wprintf_s(L"Cannot query token information: %d\n", win32Status);
        hr = HRESULT_FROM_WIN32(win32Status);
        goto e_Exit;
    }

    // Copy the SID from the tokenInfoBuffer structure to the
    // WINBIO_IDENTITY structure. 
    CopySid(
        SECURITY_MAX_SID_SIZE,
        Identity->Value.AccountSid.Data,
        tokenInfoBuffer.tokenUser.User.Sid
        );

    // Specify the size of the SID and assign WINBIO_ID_TYPE_SID
    // to the type member of the WINBIO_IDENTITY structure.
    Identity->Value.AccountSid.Size = GetLengthSid(tokenInfoBuffer.tokenUser.User.Sid);
    Identity->Type = WINBIO_ID_TYPE_SID;

e_Exit:

    if (tokenHandle != NULL)
    {
        CloseHandle(tokenHandle);
    }

    return hr;
}


요구 사항

요구 사항 가치
지원되는 최소 클라이언트 Windows 7 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 R2 [데스크톱 앱만 해당]
대상 플랫폼 윈도우즈
Header winbio.h(Winbio.h 포함)
Library Winbio.lib
DLL Winbio.dll

참고하십시오

WinBioRemoveAllCredentials

WinBioRemoveAllDomainCredentials

WinBioSetCredential