-static int get_remote_rootdse(struct ldb_context *ldb, void *context,
- struct ldb_reply *ares)
-{
- struct entryuuid_private *entryuuid_private;
- entryuuid_private = talloc_get_type(context,
- struct entryuuid_private);
- if (ares->type == LDB_REPLY_ENTRY) {
- int i;
- struct ldb_message_element *el = ldb_msg_find_element(ares->message, "namingContexts");
- entryuuid_private->base_dns = talloc_realloc(entryuuid_private, entryuuid_private->base_dns, struct ldb_dn *,
- el->num_values + 1);
- for (i=0; i < el->num_values; i++) {
- if (!entryuuid_private->base_dns) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- entryuuid_private->base_dns[i] = ldb_dn_new(entryuuid_private->base_dns, ldb, (const char *)el->values[i].data);
- if ( ! ldb_dn_validate(entryuuid_private->base_dns[i])) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- }
- entryuuid_private->base_dns[i] = NULL;
- }
-
- return LDB_SUCCESS;
-}
-
-static int find_base_dns(struct ldb_module *module,
- struct entryuuid_private *entryuuid_private)
-{
- int ret;
- struct ldb_request *req;
- const char *naming_context_attr[] = {
- "namingContexts",
- NULL
- };
- req = talloc(entryuuid_private, struct ldb_request);
- if (req == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- req->operation = LDB_SEARCH;
- req->op.search.base = ldb_dn_new(req, module->ldb, NULL);
- req->op.search.scope = LDB_SCOPE_BASE;
-
- req->op.search.tree = ldb_parse_tree(req, "objectClass=*");
- if (req->op.search.tree == NULL) {
- ldb_set_errstring(module->ldb, "Unable to parse search expression");
- talloc_free(req);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- req->op.search.attrs = naming_context_attr;
- req->controls = NULL;
- req->context = entryuuid_private;
- req->callback = get_remote_rootdse;
- ldb_set_timeout(module->ldb, req, 0); /* use default timeout */
-
- ret = ldb_next_request(module, req);
-
- if (ret == LDB_SUCCESS) {
- ret = ldb_wait(req->handle, LDB_WAIT_ALL);
- }
-
- talloc_free(req);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
- return LDB_SUCCESS;
-}
-