1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-10 13:57:47 +03:00

r10252: a recent checkin from simo changed the handling of BASE and SUBTREE

searches in ldb to be more ldap compliant, but broke the wins server
and the ejs ldb code. This fixes those up so 'make test' passes again.
This commit is contained in:
Andrew Tridgell 2005-09-16 03:18:49 +00:00 committed by Gerald (Jerry) Carter
parent 4357a2db5e
commit dff660c23c
3 changed files with 18 additions and 23 deletions

View File

@ -294,7 +294,8 @@ static NTSTATUS rootdse_Search(struct ldapsrv_partition *partition, struct ldaps
attrs[j] = NULL;
}
count = ldb_search(ldb, NULL, 0, "dn=cn=rootDSE", attrs, &res);
count = ldb_search(ldb, ldb_dn_explode(local_ctx, "cn=rootDSE"), 0,
NULL, attrs, &res);
talloc_steal(local_ctx, res);
if (count == 1) {

View File

@ -87,25 +87,21 @@ static void winsdb_remove_version(struct wins_server *winssrv, uint64_t version)
/*
return a DN for a nbt_name
*/
static char *winsdb_dn(TALLOC_CTX *mem_ctx, struct nbt_name *name)
static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct nbt_name *name)
{
char *ret = talloc_asprintf(mem_ctx, "type=%02x", name->type);
if (ret == NULL) {
return ret;
struct ldb_dn *dn;
dn = ldb_dn_string_compose(mem_ctx, NULL, "type=%02x", name->type);
if (dn == NULL) {
return NULL;
}
if (name->name && *name->name) {
ret = talloc_asprintf_append(ret, ",name=%s", name->name);
if (dn && name->name && *name->name) {
dn = ldb_dn_string_compose(mem_ctx, dn, "name=%s", name->name);
}
if (ret == NULL) {
return ret;
if (dn && name->scope && *name->scope) {
dn = ldb_dn_string_compose(mem_ctx, dn, "scope=%s", name->scope);
}
if (name->scope && *name->scope) {
ret = talloc_asprintf_append(ret, ",scope=%s", name->scope);
}
if (ret == NULL) {
return ret;
}
return ret;
return dn;
}
/*
@ -119,14 +115,11 @@ struct winsdb_record *winsdb_load(struct wins_server *winssrv,
struct winsdb_record *rec;
struct ldb_message_element *el;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
const char *expr;
int i;
expr = talloc_asprintf(tmp_ctx, "dn=%s", winsdb_dn(tmp_ctx, name));
if (expr == NULL) goto failed;
/* find the record in the WINS database */
ret = ldb_search(winssrv->wins_db, NULL, LDB_SCOPE_ONELEVEL, expr, NULL, &res);
ret = ldb_search(winssrv->wins_db, winsdb_dn(tmp_ctx, name), LDB_SCOPE_BASE,
NULL, NULL, &res);
if (res != NULL) {
talloc_steal(tmp_ctx, res);
}
@ -184,7 +177,7 @@ static struct ldb_message *winsdb_message(struct wins_server *winssrv,
struct ldb_message *msg = ldb_msg_new(mem_ctx);
if (msg == NULL) goto failed;
msg->dn = ldb_dn_explode(msg, winsdb_dn(msg, rec->name));
msg->dn = winsdb_dn(msg, rec->name);
if (msg->dn == NULL) goto failed;
ret |= ldb_msg_add_fmt(ldb, msg, "objectClass", "wins");
ret |= ldb_msg_add_fmt(ldb, msg, "active", "%u", rec->state);
@ -276,7 +269,7 @@ uint8_t winsdb_delete(struct wins_server *winssrv, struct winsdb_record *rec)
winsdb_remove_version(winssrv, rec->version);
dn = ldb_dn_explode(tmp_ctx, winsdb_dn(tmp_ctx, rec->name));
dn = winsdb_dn(tmp_ctx, rec->name);
if (dn == NULL) goto failed;
ret = ldb_delete(ldb, dn);

View File

@ -412,6 +412,7 @@ static int ejs_ldb_init(MprVarHandle eid, int argc, struct MprVar **argv)
mprSetVar(ldb, "SCOPE_BASE", mprCreateNumberVar(LDB_SCOPE_BASE));
mprSetVar(ldb, "SCOPE_ONE", mprCreateNumberVar(LDB_SCOPE_ONELEVEL));
mprSetVar(ldb, "SCOPE_SUBTREE", mprCreateNumberVar(LDB_SCOPE_SUBTREE));
mprSetVar(ldb, "SCOPE_DEFAULT", mprCreateNumberVar(LDB_SCOPE_DEFAULT));
return 0;
}