/* VmDirMDBDNToEntry: For a given entry DN, reads an entry from the entry DB. * * Returns: BE error - BACKEND_ERROR, BACKEND OPERATIONS, BACKEND_ENTRY_NOTFOUND * */ DWORD VmDirMDBDNToEntry( PVDIR_BACKEND_CTX pBECtx, PVDIR_SCHEMA_CTX pSchemaCtx, VDIR_BERVALUE* pDn, PVDIR_ENTRY pEntry, VDIR_BACKEND_ENTRY_LOCKTYPE entryLockType) { DWORD dwError = LDAP_SUCCESS; ENTRYID eId = {0}; // make sure we look up normalized dn value dwError = VmDirNormalizeDN( pDn, pSchemaCtx ); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirMDBDNToEntryId( pBECtx, pDn, &eId ); BAIL_ON_VMDIR_ERROR( dwError ); dwError = VmDirMDBEIdToEntry( pBECtx, pSchemaCtx, eId, pEntry, entryLockType ); BAIL_ON_VMDIR_ERROR( dwError ); cleanup: return dwError; error: VMDIR_LOG_ERROR( LDAP_DEBUG_BACKEND, "BEDNToEntry DN (%s) failed, (%u)(%s)", VDIR_SAFE_STRING( pDn->bvnorm_val), dwError, VDIR_SAFE_STRING(pBECtx->pszBEErrorMsg) ); VMDIR_SET_BACKEND_ERROR(dwError); // if dwError no in BE space, set to ERROR_BACKEND_ERROR goto cleanup; }
DWORD VmDirMDBSimpleEIdToEntry( PVDIR_BACKEND_INTERFACE pBE, ENTRYID eId, PVDIR_ENTRY pEntry) { DWORD dwError = 0; PVDIR_SCHEMA_CTX pSchemaCtx = NULL; VDIR_BACKEND_CTX mdbBECtx = {0}; BOOLEAN bHasTxn = FALSE; assert(pBE && pEntry); dwError = VmDirSchemaCtxAcquire(&pSchemaCtx); BAIL_ON_VMDIR_ERROR(dwError); mdbBECtx.pBE = pBE; dwError = VmDirMDBTxnBegin(&mdbBECtx, VDIR_BACKEND_TXN_READ, &bHasTxn); BAIL_ON_VMDIR_ERROR(dwError); dwError = VmDirMDBEIdToEntry( &mdbBECtx, pSchemaCtx, eId, pEntry, VDIR_BACKEND_ENTRY_LOCK_READ); BAIL_ON_VMDIR_ERROR(dwError); if (bHasTxn) { dwError = VmDirMDBTxnCommit(&mdbBECtx); bHasTxn = FALSE; BAIL_ON_VMDIR_ERROR(dwError); } cleanup: if (pSchemaCtx) { VmDirSchemaCtxRelease(pSchemaCtx); } VmDirBackendCtxContentFree(&mdbBECtx); return dwError; error: if (bHasTxn) { VmDirMDBTxnAbort(&mdbBECtx); } goto cleanup; }