Beispiel #1
0
int
VmDirPerformDelete(
   PVDIR_OPERATION pOperation
   )
{
    int              retVal = LDAP_SUCCESS;
    DeleteReq *      dr = &(pOperation->request.deleteReq);
    BOOLEAN         bResultAlreadySent = FALSE;
    // Get entry DN. 'm' => pOperation->reqDn.lberbv.bv_val points to DN within (in-place) ber
    if ( ber_scanf( pOperation->ber, "m", &(pOperation->reqDn.lberbv) ) == LBER_ERROR )
    {
        VMDIR_LOG_ERROR( LDAP_DEBUG_ARGS, "PerformDelete: ber_scanf failed" );
        retVal = LDAP_NOTICE_OF_DISCONNECT;
        BAIL_ON_VMDIR_ERROR( retVal );
    }

    VMDIR_LOG_INFO( LDAP_DEBUG_ARGS, "Delete Request: dn (%s)", pOperation->reqDn.lberbv.bv_val );

    memset( dr, 0, sizeof( DeleteReq ));

    // NOTE: pOperation->reqDn.lberbv.bv_val is NULL terminated (TODO, verify this)
    dr->dn.lberbv.bv_val = pOperation->reqDn.lberbv.bv_val;
    dr->dn.lberbv.bv_len = pOperation->reqDn.lberbv.bv_len;

    retVal = VmDirMLDelete( pOperation );
    bResultAlreadySent = TRUE;
    BAIL_ON_VMDIR_ERROR(retVal);

cleanup:

    return retVal;

error:
    if (retVal != LDAP_NOTICE_OF_DISCONNECT && bResultAlreadySent == FALSE)
    {
        VmDirSendLdapResult( pOperation );
    }

    goto cleanup;
}
Beispiel #2
0
DWORD
VmDirRESTObjectDelete(
    void*   pIn,
    void**  ppOut
    )
{
    DWORD   dwError = 0;
    PSTR    pszTenant = NULL;
    PSTR    pszDN = NULL;
    BOOLEAN bRecursive = FALSE;
    PVDIR_REST_OPERATION    pRestOp = NULL;
    PVDIR_OPERATION         pDeleteOp = NULL;

    if (!pIn)
    {
        dwError = VMDIR_ERROR_INVALID_PARAMETER;
        BAIL_ON_VMDIR_ERROR(dwError);
    }

    pRestOp = (PVDIR_REST_OPERATION)pIn;

    dwError = VmDirRESTGetBoolParam(pRestOp, "recursive", &bRecursive, FALSE);
    BAIL_ON_VMDIR_ERROR(dwError);

    // TODO implement recursive option
    dwError = bRecursive ? VMDIR_ERROR_UNWILLING_TO_PERFORM : 0;
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirExternalOperationCreate(
            NULL, -1, LDAP_REQ_DELETE, pRestOp->pConn, &pDeleteOp);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirRESTGetObjectTenantParam(pRestOp, &pszTenant);
    BAIL_ON_VMDIR_ERROR(dwError)

    dwError = VmDirRESTDecodeObjectPathToDN(
            pRestOp->pszSubPath, pszTenant, &pszDN);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirStringToBervalContent(pszDN, &pDeleteOp->reqDn);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirStringToBervalContent(pszDN, &pDeleteOp->request.deleteReq.dn);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirMLDelete(pDeleteOp);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:
    VMDIR_SET_REST_RESULT(pRestOp, pDeleteOp, dwError, NULL);
    VMDIR_SAFE_FREE_MEMORY(pszTenant);
    VMDIR_SAFE_FREE_MEMORY(pszDN);
    VmDirFreeOperation(pDeleteOp);
    return dwError;

error:
    VMDIR_LOG_ERROR(
            VMDIR_LOG_MASK_ALL,
            "%s failed, error (%d)",
            __FUNCTION__,
            dwError);

    goto cleanup;
}
Beispiel #3
0
int
VmDirPerformDelete(
   PVDIR_OPERATION pOperation
   )
{
    int         retVal = LDAP_SUCCESS;
    DeleteReq * dr = &(pOperation->request.deleteReq);
    BOOLEAN     bRefSent = FALSE;
    PSTR        pszRefStr = NULL;
    PSTR        pszLocalErrMsg = NULL;

    // Get entry DN. 'm' => pOperation->reqDn.lberbv.bv_val points to DN within (in-place) ber
    if ( ber_scanf( pOperation->ber, "m", &(pOperation->reqDn.lberbv) ) == LBER_ERROR )
    {
        VMDIR_LOG_ERROR( LDAP_DEBUG_ARGS, "PerformDelete: ber_scanf failed" );
        retVal = LDAP_NOTICE_OF_DISCONNECT;
        BAIL_ON_VMDIR_ERROR( retVal );
    }

    VMDIR_LOG_INFO( LDAP_DEBUG_ARGS, "Delete Request: dn (%s)", pOperation->reqDn.lberbv.bv_val );

    memset( dr, 0, sizeof( DeleteReq ));

    // NOTE: pOperation->reqDn.lberbv.bv_val is NULL terminated (TODO, verify this)
    dr->dn.lberbv.bv_val = pOperation->reqDn.lberbv.bv_val;
    dr->dn.lberbv.bv_len = pOperation->reqDn.lberbv.bv_len;

    retVal = ParseRequestControls(pOperation, &pOperation->ldapResult);
    BAIL_ON_VMDIR_ERROR(retVal);

    if (pOperation->manageDsaITCtrl == NULL &&
        (gVmdirGlobals.dwEnableRaftReferral & VMDIR_RAFT_ENABLE_UPDATE_REFERRAL) &&
        VmDirRaftNeedReferral(pOperation->reqDn.lberbv.bv_val))
    {
       retVal = VmDirAllocateStringPrintf(&pszRefStr, "%s",
                   pOperation->reqDn.lberbv.bv_len > 0 ? pOperation->reqDn.lberbv.bv_val:"");
       BAIL_ON_VMDIR_ERROR(retVal);

       VmDirSendLdapReferralResult(pOperation, pszRefStr, &bRefSent);
       if (bRefSent)
       {
           goto cleanup;
       }
       // Referral is not sent because the raft state might have changed. Go throughput normal procedure.
    }

    retVal = VmDirMLDelete( pOperation );
    BAIL_ON_VMDIR_ERROR(retVal);

cleanup:
    if (retVal != LDAP_NOTICE_OF_DISCONNECT && bRefSent == FALSE)
    {
        VmDirSendLdapResult( pOperation );
    }
    VMDIR_SAFE_FREE_MEMORY(pszRefStr);
    VMDIR_SAFE_FREE_MEMORY(pszLocalErrMsg);
    return retVal;

error:
    VMDIR_SET_LDAP_RESULT_ERROR(&pOperation->ldapResult, retVal, pszLocalErrMsg);
    goto cleanup;
}