2000-09-25 06:48:13 +08:00
|
|
|
/* dn2entry.c - routines to deal with the dn2id / id2entry glue */
|
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/*
|
|
|
|
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include "back-bdb.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dn2entry - look up dn in the cache/indexes and return the corresponding
|
|
|
|
* entry.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
bdb_dn2entry(
|
2000-09-28 06:28:59 +08:00
|
|
|
BackendDB *be,
|
2000-09-25 06:48:13 +08:00
|
|
|
DB_TXN *tid,
|
2000-09-28 06:28:59 +08:00
|
|
|
const char *dn,
|
2000-09-25 06:48:13 +08:00
|
|
|
Entry **e,
|
2000-09-28 06:28:59 +08:00
|
|
|
Entry **matched,
|
2000-09-25 06:48:13 +08:00
|
|
|
int flags )
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
ID id;
|
|
|
|
char *matchedDN = NULL;
|
|
|
|
|
2000-09-28 08:02:47 +08:00
|
|
|
Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry(\"%s\")\n",
|
2000-09-25 06:48:13 +08:00
|
|
|
dn, 0, 0 );
|
|
|
|
|
2000-09-27 01:47:24 +08:00
|
|
|
*e = NULL;
|
|
|
|
|
2000-09-25 06:48:13 +08:00
|
|
|
if( matched != NULL ) {
|
2000-09-27 01:47:24 +08:00
|
|
|
*matched = NULL;
|
2000-09-25 06:48:13 +08:00
|
|
|
rc = bdb_dn2id_matched( be, tid, dn, &id, &matchedDN );
|
|
|
|
} else {
|
|
|
|
rc = bdb_dn2id( be, tid, dn, &id );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rc != 0 ) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( matchedDN == NULL ) {
|
|
|
|
rc = bdb_id2entry( be, tid, id, e );
|
|
|
|
} else {
|
|
|
|
rc = bdb_id2entry( be, tid, id, matched );
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
2000-09-27 01:47:24 +08:00
|
|
|
}
|