Example #1
0
VOID
EVTFreeSidArray(
    PLW_MAP_SECURITY_CONTEXT pContext,
    DWORD dwCount,
    PSID* ppSidArray
    )
{
    DWORD dwInputIndex = 0;

    for (dwInputIndex = 0; dwInputIndex < dwCount; dwInputIndex++)
    {
        LwMapSecurityFreeSid(pContext, &ppSidArray[dwInputIndex]);
    }
    LW_SAFE_FREE_MEMORY(ppSidArray);
}
Example #2
0
static
DWORD
NtlmGetLocalGuestAccountSid(
    OUT PSTR* ppszGuestSid
    )
{
    DWORD dwError = LW_ERROR_SUCCESS;
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PLW_MAP_SECURITY_CONTEXT pContext = NULL;
    PSID pGuestSid = NULL;
    PSTR pszGuestSid = NULL;

    ntStatus = LwMapSecurityCreateContext(&pContext);
    dwError = LwNtStatusToWin32Error(ntStatus);
    BAIL_ON_LSA_ERROR(dwError);

    ntStatus = LwMapSecurityGetLocalGuestAccountSid(pContext, &pGuestSid);
    dwError = LwNtStatusToWin32Error(ntStatus);
    BAIL_ON_LSA_ERROR(dwError);

    ntStatus = RtlAllocateCStringFromSid(&pszGuestSid, pGuestSid);
    dwError = LwNtStatusToWin32Error(ntStatus);
    BAIL_ON_LSA_ERROR(dwError);

cleanup:

    if (pContext && pGuestSid)
    {
        LwMapSecurityFreeSid(pContext, &pGuestSid);
    }
    LwMapSecurityFreeContext(&pContext);

    *ppszGuestSid = pszGuestSid;

    return dwError;

error:

    LW_SAFE_FREE_STRING(pszGuestSid);

    goto cleanup;
}