summaryrefslogtreecommitdiff
path: root/source4/nbt_server
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-09-16 03:18:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:11 -0500
commit95040e934175eb877ce6d83690fd06ce5d2b028c (patch)
tree88640eecd903be05f1fb7e96a2300d84a0402989 /source4/nbt_server
parentd8da5e4fb7534d2931a01bfc4b6f59bdca206c65 (diff)
downloadsamba-95040e934175eb877ce6d83690fd06ce5d2b028c.tar.gz
samba-95040e934175eb877ce6d83690fd06ce5d2b028c.tar.bz2
samba-95040e934175eb877ce6d83690fd06ce5d2b028c.zip
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 used to be commit dff660c23c97114d0c1be705f4d6a9c114b60456)
Diffstat (limited to 'source4/nbt_server')
-rw-r--r--source4/nbt_server/wins/winsdb.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index a83c60c3e7..75d08227d9 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -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;
- }
- if (name->name && *name->name) {
- ret = talloc_asprintf_append(ret, ",name=%s", name->name);
- }
- 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->scope && *name->scope) {
- ret = talloc_asprintf_append(ret, ",scope=%s", name->scope);
+ 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);
}
- 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);