Пример #1
0
NTSTATUS
LsaAllocateTranslatedSids3(
    OUT TranslatedSid3       *pOut,
    IN OUT PDWORD             pdwOffset,
    IN OUT PDWORD             pdwSpaceLeft,
    IN  TranslatedSidArray3  *pIn,
    IN OUT PDWORD             pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;
    PVOID pBuffer = pOut;
    DWORD iTransSid = 0;

    BAIL_ON_INVALID_PTR(pdwOffset, ntStatus);
    BAIL_ON_INVALID_PTR(pIn, ntStatus);
    BAIL_ON_INVALID_PTR(pdwSize, ntStatus);

    for (iTransSid = 0; iTransSid < pIn->count; iTransSid++)
    {
        LWBUF_ALLOC_WORD(pBuffer, pIn->sids[iTransSid].type);
        LWBUF_ALIGN_PTR(pdwOffset, pdwSize, pdwSpaceLeft);

        if (pIn->sids[iTransSid].sid)
        {
            LWBUF_ALLOC_PSID(pBuffer, pIn->sids[iTransSid].sid);
        }
        else if (pIn->sids[iTransSid].type == SID_TYPE_DOMAIN ||
                 pIn->sids[iTransSid].type == SID_TYPE_INVALID ||
                 pIn->sids[iTransSid].type == SID_TYPE_UNKNOWN)
        {
            LWBUF_ALLOC_PSID(pBuffer, NULL);
        }
        else
        {
            ntStatus = STATUS_INVALID_SID;
            BAIL_ON_NT_STATUS(ntStatus);
        }

        LWBUF_ALLOC_DWORD(pBuffer, pIn->sids[iTransSid].index);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->sids[iTransSid].unknown1);
    }

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}
Пример #2
0
static
NTSTATUS
NetrAllocateSidAttr(
    OUT NetrSidAttr  *pOut,
    IN OUT PDWORD     pdwOffset,
    IN OUT PDWORD     pdwSpaceLeft,
    IN  NetrSidAttr  *pIn,
    IN OUT PDWORD     pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;
    PVOID pBuffer = pOut;

    BAIL_ON_INVALID_PTR(pdwOffset, ntStatus);
    BAIL_ON_INVALID_PTR(pIn, ntStatus);
    BAIL_ON_INVALID_PTR(pdwSize, ntStatus);
    
    LWBUF_ALLOC_PSID(pBuffer, pIn->sid);
    LWBUF_ALLOC_DWORD(pBuffer, pIn->attribute);
    LWBUF_ALIGN(pdwOffset, pdwSize, pdwSpaceLeft);

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}
Пример #3
0
static
NTSTATUS
LsaAllocateDomainInfo(
    OUT PVOID          pBuffer,
    IN OUT PDWORD      pdwOffset,
    IN OUT PDWORD      pdwSpaceLeft,
    IN LsaDomainInfo  *pIn,
    IN OUT PDWORD      pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;

    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->name);
    LWBUF_ALLOC_PSID(pBuffer, pIn->sid);

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}
Пример #4
0
NTSTATUS
NetrAllocateDomainTrusts(
    OUT NetrDomainTrust      *pOut,
    IN OUT PDWORD             pdwOffset,
    IN OUT PDWORD             pdwSpaceLeft,
    IN  NetrDomainTrustList  *pIn,
    IN OUT PDWORD             pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;
    PVOID pBuffer = pOut;
    UINT32 i = 0;

    BAIL_ON_INVALID_PTR(pdwOffset, ntStatus);
    BAIL_ON_INVALID_PTR(pIn, ntStatus);
    BAIL_ON_INVALID_PTR(pdwSize, ntStatus);

    for (i = 0; i < pIn->count; i++)
    {
        LWBUF_ALLOC_PWSTR(pBuffer, pIn->array[i].netbios_name);
        LWBUF_ALLOC_PWSTR(pBuffer, pIn->array[i].dns_name);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->array[i].trust_flags);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->array[i].parent_index);
        LWBUF_ALLOC_WORD(pBuffer, pIn->array[i].trust_type);
        LWBUF_ALIGN_TYPE(pdwOffset, pdwSize, pdwSpaceLeft, DWORD);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->array[i].trust_attrs);
        LWBUF_ALLOC_PSID(pBuffer, pIn->array[i].sid);
        LWBUF_ALLOC_BLOB(pBuffer,
                         sizeof(pIn->array[i].guid),
                         &(pIn->array[i].guid));
    }

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}
Пример #5
0
static
NTSTATUS
NetrAllocateDomainTrustInfo(
    OUT NetrDomainTrustInfo *pOut,
    IN OUT PDWORD            pdwOffset,
    IN OUT PDWORD            pdwSpaceLeft,
    IN  NetrDomainTrustInfo *pIn,
    IN OUT PDWORD            pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;
    NetrDomainTrustInfo *pBuffer = pOut;

    BAIL_ON_INVALID_PTR(pdwOffset, ntStatus);
    BAIL_ON_INVALID_PTR(pIn, ntStatus);
    BAIL_ON_INVALID_PTR(pdwSize, ntStatus);

    LWBUF_ALIGN(pdwOffset, pdwSize, pdwSpaceLeft);

    LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                               (PUNICODE_STRING)&pIn->domain_name);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                               (PUNICODE_STRING)&pIn->full_domain_name);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                               (PUNICODE_STRING)&pIn->forest);
    LWBUF_ALLOC_BLOB(pBuffer, sizeof(pIn->guid), &pIn->guid);
    LWBUF_ALLOC_PSID(pBuffer, pIn->sid);

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}
Пример #6
0
NTSTATUS
LsaAllocateSids(
    OUT PSID                    *pOut,
    IN OUT PDWORD                pdwOffset,
    IN OUT PDWORD                pdwSpaceLeft,
    IN PLSA_ACCOUNT_ENUM_BUFFER  pIn,
    IN OUT PDWORD                pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;
    PVOID pBuffer = pOut;
    DWORD iSid = 0;

    BAIL_ON_INVALID_PTR(pdwOffset, ntStatus);
    BAIL_ON_INVALID_PTR(pIn, ntStatus);
    BAIL_ON_INVALID_PTR(pdwSize, ntStatus);

    for (iSid = 0; iSid < pIn->NumAccounts; iSid++)
    {
        LWBUF_ALIGN(pdwOffset, pdwSize, pdwSpaceLeft);
        LWBUF_ALLOC_PSID(pBuffer, pIn->pAccount[iSid].pSid);
    }

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}
Пример #7
0
static
NTSTATUS
NetrInitSamBaseInfo(
    OUT NetrSamBaseInfo *pOut,
    IN OUT PDWORD        pdwOffset,
    IN OUT PDWORD        pdwSpaceLeft,
    IN  NetrSamBaseInfo *pIn,
    IN OUT PDWORD        pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;
    PVOID pBuffer = pOut;

    BAIL_ON_INVALID_PTR(pdwOffset, ntStatus);
    BAIL_ON_INVALID_PTR(pIn, ntStatus);
    BAIL_ON_INVALID_PTR(pdwSize, ntStatus);

    LWBUF_ALIGN(pdwOffset, pdwSize, pdwSpaceLeft);

    LWBUF_ALLOC_WINNTTIME(pBuffer, pIn->last_logon);
    LWBUF_ALLOC_WINNTTIME(pBuffer, pIn->last_logoff);
    LWBUF_ALLOC_WINNTTIME(pBuffer, pIn->acct_expiry);
    LWBUF_ALLOC_WINNTTIME(pBuffer, pIn->last_password_change);
    LWBUF_ALLOC_WINNTTIME(pBuffer, pIn->allow_password_change);
    LWBUF_ALLOC_WINNTTIME(pBuffer, pIn->force_password_change);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->account_name);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->full_name);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->logon_script);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->profile_path);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->home_directory);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->home_drive);
    LWBUF_ALLOC_WORD(pBuffer, pIn->logon_count);
    LWBUF_ALLOC_WORD(pBuffer, pIn->bad_password_count);
    LWBUF_ALLOC_DWORD(pBuffer, pIn->rid);
    LWBUF_ALLOC_DWORD(pBuffer, pIn->primary_gid);

    ntStatus = NetrAllocateRidWithAttributeArray(pBuffer,
                                                 pdwOffset,
                                                 pdwSpaceLeft,
                                                 &pIn->groups,
                                                 pdwSize);
    BAIL_ON_NT_STATUS(ntStatus);

    LWBUF_ALLOC_DWORD(pBuffer, pIn->user_flags);
    LWBUF_ALLOC_SESSION_KEY(pBuffer, &pIn->key);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->logon_server);
    LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->domain);
    LWBUF_ALLOC_PSID(pBuffer, pIn->domain_sid);
    LWBUF_ALLOC_SESSION_KEY(pBuffer, &pIn->lmkey);
    LWBUF_ALLOC_DWORD(pBuffer, pIn->acct_flags);
    LWBUF_ALLOC_BLOB(pBuffer, sizeof(pIn->unknown), pIn->unknown);

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}
Пример #8
0
NTSTATUS
LsaAllocatePolicyInformation(
    OUT LsaPolicyInformation *pOut,
    IN OUT PDWORD             pdwOffset,
    IN OUT PDWORD             pdwSpaceLeft,
    IN  WORD                  swLevel,
    IN  LsaPolicyInformation *pIn,
    IN OUT PDWORD             pdwSize
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    DWORD dwError = ERROR_SUCCESS;
    PVOID pBuffer = pOut;

    BAIL_ON_INVALID_PTR(pdwOffset, ntStatus);
    BAIL_ON_INVALID_PTR(pIn, ntStatus);
    BAIL_ON_INVALID_PTR(pdwSize, ntStatus);

    switch (swLevel)
    {
    case LSA_POLICY_INFO_AUDIT_LOG:
        LWBUF_ALLOC_DWORD(pBuffer, pIn->audit_log.percent_full);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->audit_log.log_size);
        LWBUF_ALLOC_NTTIME(pBuffer, pIn->audit_log.retention_time);
        LWBUF_ALLOC_BYTE(pBuffer, pIn->audit_log.shutdown_in_progress);
        LWBUF_ALLOC_NTTIME(pBuffer, pIn->audit_log.time_to_shutdown);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->audit_log.next_audit_record);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->audit_log.unknown);
        break;

    case LSA_POLICY_INFO_AUDIT_EVENTS:
        ntStatus = LsaAllocateAuditEventsInfo(pBuffer,
                                              pdwOffset,
                                              pdwSpaceLeft,
                                              &pIn->audit_events,
                                              pdwSize);
        break;

    case LSA_POLICY_INFO_DOMAIN:
        ntStatus = LsaAllocateDomainInfo(pBuffer,
                                         pdwOffset,
                                         pdwSpaceLeft,
                                         &pIn->domain,
                                         pdwSize);
        break;

    case LSA_POLICY_INFO_PD:
        LWBUF_ALLOC_UNICODE_STRING(pBuffer, (PUNICODE_STRING)&pIn->pd.name);
        break;

    case LSA_POLICY_INFO_ACCOUNT_DOMAIN:
        ntStatus = LsaAllocateDomainInfo(pBuffer,
                                         pdwOffset,
                                         pdwSpaceLeft,
                                         &pIn->account_domain,
                                         pdwSize);
        break;

    case LSA_POLICY_INFO_ROLE:
        LWBUF_ALLOC_WORD(pBuffer, pIn->role.unknown);
        LWBUF_ALLOC_WORD(pBuffer, pIn->role.role);
        break;

    case LSA_POLICY_INFO_REPLICA:
        LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                                   (PUNICODE_STRING)&pIn->replica.source);
        LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                                   (PUNICODE_STRING)&pIn->replica.account);
        break;

    case LSA_POLICY_INFO_QUOTA:
        LWBUF_ALLOC_DWORD(pBuffer, pIn->quota.paged_pool);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->quota.non_paged_pool);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->quota.min_wss);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->quota.max_wss);
        LWBUF_ALLOC_DWORD(pBuffer, pIn->quota.pagefile);
        LWBUF_ALLOC_ULONG64(pBuffer, pIn->quota.unknown);
        break;

    case LSA_POLICY_INFO_DB:
        LWBUF_ALLOC_ULONG64(pBuffer, pIn->db.modified_id);
        LWBUF_ALLOC_NTTIME(pBuffer, pIn->db.db_create_time);
        break;

    case LSA_POLICY_INFO_AUDIT_FULL_SET:
        LWBUF_ALLOC_BYTE(pBuffer, pIn->audit_set.shutdown_on_full);
        break;

    case LSA_POLICY_INFO_AUDIT_FULL_QUERY:
        LWBUF_ALLOC_WORD(pBuffer, pIn->audit_query.unknown);
        LWBUF_ALLOC_BYTE(pBuffer, pIn->audit_query.shutdown_on_full);
        LWBUF_ALLOC_BYTE(pBuffer, pIn->audit_query.log_is_full);
        break;

    case LSA_POLICY_INFO_DNS:
        LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                                   (PUNICODE_STRING)&pIn->dns.name);
        LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                                   (PUNICODE_STRING)&pIn->dns.dns_domain);
        LWBUF_ALLOC_UNICODE_STRING(pBuffer,
                                   (PUNICODE_STRING)&pIn->dns.dns_forest);
        LWBUF_ALIGN(pdwOffset, pdwSize, pdwSpaceLeft);
        LWBUF_ALLOC_BLOB(pBuffer,
                         sizeof(pIn->dns.domain_guid),
                         (PBYTE)&(pIn->dns.domain_guid));
        LWBUF_ALLOC_PSID(pBuffer, pIn->dns.sid);
        break;

    default:
        ntStatus = STATUS_INVALID_LEVEL;
        BAIL_ON_NT_STATUS(ntStatus);
    }

cleanup:
    if (ntStatus == STATUS_SUCCESS &&
        dwError != ERROR_SUCCESS)
    {
        ntStatus = LwWin32ErrorToNtStatus(dwError);
    }

    return ntStatus;

error:
    goto cleanup;
}