ldb_search returns LDB_ERR_NO_SUCH_OBJECT when searching forprefixMap from module - Samba
This is a discussion on ldb_search returns LDB_ERR_NO_SUCH_OBJECT when searching forprefixMap from module - Samba ; Hi List,
I added a module in dsdb/samdb/ldb_modules called prefix_map. All I need in my init function is to get the prefix map and store it,
but I fail when I do ldb_search with error LDB_ERR_NO_SUCH_OBJECT.
I tried to copy/paste ...
-
ldb_search returns LDB_ERR_NO_SUCH_OBJECT when searching forprefixMap from module
Hi List,
I added a module in dsdb/samdb/ldb_modules called prefix_map. All I need in my init function is to get the prefix map and store it,
but I fail when I do ldb_search with error LDB_ERR_NO_SUCH_OBJECT.
I tried to copy/paste the code from schema_fsmo_init method and it doesn't work in my function also.
I guess my module is not called when it should.
Here is what I have done so far.
I added it to the build system in dsdb/samdb/ldb_modules/config.mk
################################################
# Start MODULE ldb_prefix_map
[MODULE::ldb_prefix_map]
INIT_FUNCTION = LDB_MODULE(prefix_map)
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBNDR NDR_MISC NDR_DRSUAPI \
NDR_DRSBLOBS LIBNDR
SUBSYSTEM = LIBLDB
# End MODULE ldb_prefix_map
################################################
ldb_prefix_map_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/prefix_map.o
Edited the scripting/python/samba/provision.py to put it in the chain
modules_list = ["rootdse",
"paged_results",
"ranged_results",
"anr",
"server_sort",
"extended_dn",
"asq",
"rdn_name",
"objectclass",
"samldb",
"kludge_acl",
"operational",
"prefix_map"]
And added code to the .init_context function
static int prefix_map_init(struct ldb_module *module)
{
const struct ldb_val *prefix_val;
struct ldb_val *prefix_map_string;
struct ldb_dn *schema_dn;
struct ldb_result *schema_res;
int ret;
TALLOC_CTX *mem_ctx;
static const char *schema_attrs[] = {
"prefixMap",
NULL
};
schema_dn = samdb_schema_dn(module->ldb);
if (!schema_dn) {
ldb_reset_err_string(module->ldb);
ldb_debug(module->ldb, LDB_DEBUG_WARNING,
"prefix_map_init: no schema dn present: (skip prefix map init)\n");
return ldb_next_init(module);
}
mem_ctx = talloc_new(module);
if (!mem_ctx) {
ldb_debug(module->ldb, LDB_DEBUG_WARNING,
"prefix_map_init: talloc failed: (skip prefix map init)\n");
return ldb_next_init(module);
}
ret = ldb_search(module->ldb, schema_dn,
LDB_SCOPE_BASE,
NULL, schema_attrs,
&schema_res);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
ldb_reset_err_string(module->ldb);
ldb_debug(module->ldb, LDB_DEBUG_WARNING,
"prefix_map_init: no prefix map present: (skip prefix map init)\n");
talloc_free(mem_ctx);
return ldb_next_init(module);
} else if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(module->ldb,
"prefix_map_init: failed to search the schema head: %s",
ldb_errstring(module->ldb));
talloc_free(mem_ctx);
return ret;
}
prefix_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "prefixMap");
if (!prefix_val) {
ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
"prefix_map_init: no prefixMap attribute found");
talloc_free(mem_ctx);
return ldb_next_init(module);
}
prefix_map_string = talloc( mem_ctx, struct ldb_val );
if ( !ldif_write_prefixMap(module->ldb, mem_ctx, prefix_val, prefix_map_string) ) {
ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
"prefix_map_init: cannot convert a NDR formatted blob to a ldif formatted prefixMap");
talloc_free(mem_ctx);
return ldb_next_init(module);
}
talloc_free(mem_ctx);
return ldb_next_init(module);
}
Regards,
Anatoliy Atanasov
-
Re: ldb_search returns LDB_ERR_NO_SUCH_OBJECT when searching forprefixMap from module
On Tue, 2008-06-24 at 13:15 +0300, Anatoliy Atanasov wrote:
> Hi List,
>
> I added a module in dsdb/samdb/ldb_modules called prefix_map. All I need in my init function is to get the prefix map and store it,
> but I fail when I do ldb_search with error LDB_ERR_NO_SUCH_OBJECT.
> I tried to copy/paste the code from schema_fsmo_init method and it doesn't work in my function also.
> I guess my module is not called when it should.
>
> Here is what I have done so far.
Could you post that as a diff -u? Say with 'git diff'?
That way, I can try out the code, and give you more useful feedback.
(it should also be easier than hand-composing it into a mail :-)
Thanks,
Andrew Bartlett
--
Andrew Bartlett
http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
Samba Developer, Red Hat Inc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iD8DBQBIYNAcz4A8Wyi0NrsRAs8ZAJ4zUSdWlCZFThqMgNHVqa e1dJKP8gCfQwlv
XzsDgg6pFvDDhHxQXJGJ3s8=
=b2em
-----END PGP SIGNATURE-----
-
Re: ldb_search returns LDB_ERR_NO_SUCH_OBJECT when searching forprefixMap from module
Hi Anatoliy,
> I added a module in dsdb/samdb/ldb_modules called prefix_map. All I need in my init function is to get the prefix map and store it,
> but I fail when I do ldb_search with error LDB_ERR_NO_SUCH_OBJECT.
> I tried to copy/paste the code from schema_fsmo_init method and it doesn't work in my function also.
> I guess my module is not called when it should.
Can you please explain, what your module is about to do in the end?
metze
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIYNPjm70gjA5TCD8RAviEAJ9seExjlwIqvZH3D534G3 5hLV8whQCgji0A
0gckPlnpgORo//0cY1bv68I=
=piYt
-----END PGP SIGNATURE-----