summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-05-29 01:20:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:53:00 -0500
commit5fb459e4fa3201a3d5cbc22c5ff011bfc98a9519 (patch)
tree7bfef694058416ed31fcce643f65b04977fcd419 /source4/lib/ldb
parentb8b580dbcb0468306b89e0a37589700dee6ca7b8 (diff)
downloadsamba-5fb459e4fa3201a3d5cbc22c5ff011bfc98a9519.tar.gz
samba-5fb459e4fa3201a3d5cbc22c5ff011bfc98a9519.tar.bz2
samba-5fb459e4fa3201a3d5cbc22c5ff011bfc98a9519.zip
r23177: Add in a new provision-backend script. This helps set up the OpenLDAP or Fedora DS backend.
This required a new mkdir() call in ejs. We can now provision just the schema for ad2oLschema to operate on (with provision_schema(), without performing the whole provision, just to wipe it again (adjustments to 'make test' to come soon). Andrew Bartlett (This used to be commit 01d54d13dc66ef2127ac52c64ede53d0790738ec)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/tools/ad2oLschema.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c
index d04260103d..4cc07a52d8 100644
--- a/source4/lib/ldb/tools/ad2oLschema.c
+++ b/source4/lib/ldb/tools/ad2oLschema.c
@@ -195,9 +195,11 @@ static int fetch_objectclass_schema(struct ldb_context *ldb, struct ldb_dn *sche
static struct ldb_dn *find_schema_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ctx)
{
const char *rootdse_attrs[] = {"schemaNamingContext", NULL};
+ const char *no_attrs[] = { NULL };
struct ldb_dn *schemadn;
struct ldb_dn *basedn = ldb_dn_new(mem_ctx, ldb, NULL);
struct ldb_result *rootdse_res;
+ struct ldb_result *schema_res;
int ldb_ret;
if (!basedn) {
return NULL;
@@ -206,8 +208,25 @@ static struct ldb_dn *find_schema_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ct
/* Search for rootdse */
ldb_ret = ldb_search(ldb, basedn, LDB_SCOPE_BASE, NULL, rootdse_attrs, &rootdse_res);
if (ldb_ret != LDB_SUCCESS) {
- printf("Search failed: %s\n", ldb_errstring(ldb));
- return NULL;
+ ldb_ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE,
+ "(&(objectClass=dMD)(cn=Schema))",
+ no_attrs, &schema_res);
+ if (ldb_ret) {
+ printf("cn=Schema Search failed: %s\n", ldb_errstring(ldb));
+ return NULL;
+ }
+
+ talloc_steal(mem_ctx, schema_res);
+
+ if (schema_res->count != 1) {
+ printf("Failed to find rootDSE");
+ return NULL;
+ }
+
+ schemadn = talloc_steal(mem_ctx, schema_res->msgs[0]->dn);
+ talloc_free(schema_res);
+ return schemadn;
+
}
talloc_steal(mem_ctx, rootdse_res);