Beispiel #1
0
DWORD
VmDirTestDeleteContainerByDn(
    LDAP *pLd,
    PCSTR pszContainerDn
    )
{
    DWORD dwError = 0;
    DWORD dwIndex = 0;
    PVMDIR_STRING_LIST pObjectList = NULL;

    dwError = VmDirTestGetObjectList(pLd, pszContainerDn, &pObjectList);
    BAIL_ON_VMDIR_ERROR(dwError);

    for (dwIndex = 0; dwIndex < pObjectList->dwCount; ++dwIndex)
    {
        dwError = ldap_delete_ext_s(
                pLd, pObjectList->pStringList[dwIndex], NULL, NULL);
        if (dwError == LDAP_NOT_ALLOWED_ON_NONLEAF)
        {
            dwError = VmDirTestDeleteContainerByDn(
                    pLd, pObjectList->pStringList[dwIndex]);
            BAIL_ON_VMDIR_ERROR(dwError);
        }
    }

    dwError = ldap_delete_ext_s(pLd, pszContainerDn, NULL, NULL);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:
    VmDirStringListFree(pObjectList);
    return dwError;

error:
    goto cleanup;
}
Beispiel #2
0
DWORD
VmDirTestDeleteContainer(
    PVMDIR_TEST_STATE pState,
    PCSTR pszContainer
    )
{
    DWORD   dwError = 0;
    PSTR    pszDN = NULL;

    if (IsNullOrEmptyString(pszContainer))
    {
        dwError = VmDirAllocateStringPrintf(
                &pszDN,
                "cn=%s,%s",
                VmDirTestGetTestContainerCn(pState),
                pState->pszBaseDN);
        BAIL_ON_VMDIR_ERROR(dwError);
    }
    else
    {
        dwError = VmDirAllocateStringPrintf(
                &pszDN,
                "cn=%s,cn=%s,%s",
                pszContainer,
                VmDirTestGetTestContainerCn(pState),
                pState->pszBaseDN);
        BAIL_ON_VMDIR_ERROR(dwError);
    }

    dwError = VmDirTestDeleteContainerByDn(pState->pLd, pszDN);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:
    VMDIR_SAFE_FREE_STRINGA(pszDN);
    return dwError;

error:
    goto cleanup;
}