diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-06-18 09:48:17 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:18:26 -0500 |
commit | 97318cdb45f1022ca2beebbf24ab11af80c07dc2 (patch) | |
tree | f68117f9380d06532add2566a330656b7704a92f /source4 | |
parent | ca91a8a6919b9bc1b6016310c6b30447723b08d6 (diff) | |
download | samba-97318cdb45f1022ca2beebbf24ab11af80c07dc2.tar.gz samba-97318cdb45f1022ca2beebbf24ab11af80c07dc2.tar.bz2 samba-97318cdb45f1022ca2beebbf24ab11af80c07dc2.zip |
r7719: make the ildap ldb backend use the defaultNamingContext if the basedn
is not specified, so:
ldbsearch ldap://hostname '(objectclass=user)'
works without knowing the domain name
(This used to be commit f6c2c5190737ca11f55a147f5295ccca505fb58b)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/ldb_ildap/ldb_ildap.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 9cccec0313..3f63af482f 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -37,9 +37,9 @@ #include "lib/cmdline/popt_common.h" struct ildb_private { - const char *basedn; struct ldap_connection *ldap; NTSTATUS last_rc; + struct ldb_message *rootDSE; }; /* @@ -100,6 +100,8 @@ static int ildb_delete(struct ldb_module *module, const char *dn) } +static void ildb_rootdse(struct ldb_module *module); + /* search for matching records */ @@ -116,7 +118,13 @@ static int ildb_search(struct ldb_module *module, const char *base, } if (base == NULL) { - base = ""; + if (ildb->rootDSE == NULL) { + ildb_rootdse(module); + } + if (ildb->rootDSE != NULL) { + base = ldb_msg_find_string(ildb->rootDSE, + "defaultNamingContext", ""); + } } if (expression == NULL || expression[0] == '\0') { @@ -352,6 +360,22 @@ static const struct ldb_module_ops ildb_ops = { /* + fetch the rootDSE +*/ +static void ildb_rootdse(struct ldb_module *module) +{ + struct ildb_private *ildb = module->private_data; + struct ldb_message **res = NULL; + int ret; + ret = ildb_search(module, "", LDB_SCOPE_BASE, "dn=dc=rootDSE", NULL, &res); + if (ret == 1) { + ildb->rootDSE = talloc_steal(ildb, res[0]); + } + talloc_free(res); +} + + +/* connect to the database */ int ildb_connect(struct ldb_context *ldb, const char *url, @@ -366,6 +390,8 @@ int ildb_connect(struct ldb_context *ldb, const char *url, goto failed; } + ildb->rootDSE = NULL; + ildb->ldap = ldap_new_connection(ildb, NULL); if (!ildb->ldap) { ldb_oom(ldb); |