[SCM] Samba Shared Repository - branch master updated
Andrew Tridgell
tridge at samba.org
Thu Aug 11 21:19:02 MDT 2011
The branch, master has been updated
via 4aba775 tevent: don't force the nesting flag to false in the destructor
via f444eeb s4-dbcheck: offer to fix dsServiceName to be in GUID form
via fb490d8 s4-dsdb: don't cache the NTDS settings DN
via bb6214d s4-join: make dsServiceName a GUID in @ROOTDSE on join
via d79ee18 s4-provision: create dsServiceName in @ROOTDSE in GUID form
via ccba16c s4-dsdb: expand dsServiceName from GUID form at runtime
via f7902d7 s4-dsdb: remove the naming_fsmo and pdc_fsmo modules
via f9d10a3 s4-dsdb: calculate validFSMOs at runtime instead of pre-computing
from ce93b4f tevent: fix documentation for tevent_context_init_byname()
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 4aba7752195ffda980abf4a98b870d113615f662
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Aug 12 11:56:28 2011 +1000
tevent: don't force the nesting flag to false in the destructor
the tevent destructor is called in tevent_re_initialise(), to reset
the event context back to its original state for creating child
processes. We need the nesting flag to stay the same
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
Autobuild-User: Andrew Tridgell <tridge at samba.org>
Autobuild-Date: Fri Aug 12 05:18:25 CEST 2011 on sn-devel-104
commit f444eeb51c358a8062ba6e00101f88b753d69fc7
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Aug 11 16:59:11 2011 +1000
s4-dbcheck: offer to fix dsServiceName to be in GUID form
this fixes the dsServiceName so it can handle server renames
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit fb490d88c1b43ae95ef8be7c32be4f3562eba4e2
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Aug 11 16:29:24 2011 +1000
s4-dsdb: don't cache the NTDS settings DN
this DN can change due to a server rename, so we cannot cache it. It
is set by provision, but not anywhere else.
This seems to not have a large performance impact
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit bb6214d63440d52227ea94d1788b6875b4d4742c
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Aug 11 16:05:11 2011 +1000
s4-join: make dsServiceName a GUID in @ROOTDSE on join
when joining another domain as a DC we should setup our dsServiceName
in @ROOTDSE to be a GUID so we can cope with later server renames
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit d79ee18f988d1f43eb1f76752e749385b9b9c251
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Aug 11 15:45:43 2011 +1000
s4-provision: create dsServiceName in @ROOTDSE in GUID form
this allows for handling of server renames as the GUID doesn't change
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit ccba16c4b8de285f55683011c1527af3f6f48460
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Aug 11 15:44:32 2011 +1000
s4-dsdb: expand dsServiceName from GUID form at runtime
this allows dsServiceName to be stored as an extended DN or GUID form
in @ROOTDSE, and its string form will be found at runtime.
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit f7902d766a0866d92e728449377a406f8e202b2a
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Aug 11 15:43:22 2011 +1000
s4-dsdb: remove the naming_fsmo and pdc_fsmo modules
these are not needed now that the rootdse modules calculates the
validFSMOs attribute at runtime
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit f9d10a304d0197cc1ef5b14ab523d6462040088a
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Aug 11 15:40:53 2011 +1000
s4-dsdb: calculate validFSMOs at runtime instead of pre-computing
this changes the rootdse to compute the validFSMOs attribute at
runtime by checking the fSMORoleOwner attribute on the appropriate
DN. This avoids the need for the pdc_fsmo and naming_fsmo modules.
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/tevent/tevent.c | 10 +-
source4/dsdb/common/util.c | 17 +--
source4/dsdb/samdb/ldb_modules/naming_fsmo.c | 108 ----------------
source4/dsdb/samdb/ldb_modules/pdc_fsmo.c | 113 ----------------
source4/dsdb/samdb/ldb_modules/rootdse.c | 135 ++++++++++++++-----
source4/dsdb/samdb/ldb_modules/samba_dsdb.c | 12 --
source4/dsdb/samdb/ldb_modules/wscript_build | 20 ---
source4/dsdb/samdb/samdb.h | 10 --
source4/scripting/python/samba/dbchecker.py | 43 ++++++
source4/scripting/python/samba/join.py | 8 +-
.../scripting/python/samba/provision/__init__.py | 3 +-
source4/setup/provision_rootdse_modify.ldif | 2 +
12 files changed, 166 insertions(+), 315 deletions(-)
delete mode 100644 source4/dsdb/samdb/ldb_modules/naming_fsmo.c
delete mode 100644 source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
Changeset truncated at 500 lines:
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index 51555ba..a87865b 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -185,9 +185,13 @@ int tevent_common_context_destructor(struct tevent_context *ev)
tevent_cleanup_pending_signal_handlers(se);
}
- /* clean up nesting or we get an abort when nesting
- * is not allowed. -- SSS */
- ev->nesting.allowed = false;
+ /* removing nesting hook or we get an abort when nesting is
+ * not allowed. -- SSS
+ * Note that we need to leave the allowed flag at its current
+ * value, otherwise the use in tevent_re_initialise() will
+ * leave the event context with allowed forced to false, which
+ * will break users that expect nesting to be allowed
+ */
ev->nesting.level = 0;
ev->nesting.hook_fn = NULL;
ev->nesting.hook_private = NULL;
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index f306748..3b287e3 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -1252,9 +1252,9 @@ bool samdb_set_ntds_settings_dn(struct ldb_context *ldb, struct ldb_dn *ntds_set
struct ldb_dn *ntds_settings_dn_new;
struct ldb_dn *ntds_settings_dn_old;
- /* see if we have a cached copy */
+ /* see if we have a forced copy from provision */
ntds_settings_dn_old = talloc_get_type(ldb_get_opaque(ldb,
- "cache.ntds_settings_dn"), struct ldb_dn);
+ "forced.ntds_settings_dn"), struct ldb_dn);
tmp_ctx = talloc_new(ldb);
if (tmp_ctx == NULL) {
@@ -1266,8 +1266,8 @@ bool samdb_set_ntds_settings_dn(struct ldb_context *ldb, struct ldb_dn *ntds_set
goto failed;
}
- /* cache the domain_sid in the ldb */
- if (ldb_set_opaque(ldb, "cache.ntds_settings_dn", ntds_settings_dn_new) != LDB_SUCCESS) {
+ /* set the DN in the ldb to avoid lookups during provision */
+ if (ldb_set_opaque(ldb, "forced.ntds_settings_dn", ntds_settings_dn_new) != LDB_SUCCESS) {
goto failed;
}
@@ -1295,7 +1295,7 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb)
struct ldb_dn *settings_dn;
/* see if we have a cached copy */
- settings_dn = (struct ldb_dn *)ldb_get_opaque(ldb, "cache.ntds_settings_dn");
+ settings_dn = (struct ldb_dn *)ldb_get_opaque(ldb, "forced.ntds_settings_dn");
if (settings_dn) {
return settings_dn;
}
@@ -1318,10 +1318,9 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb)
settings_dn = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, root_res->msgs[0], "dsServiceName");
- /* cache the domain_sid in the ldb */
- if (ldb_set_opaque(ldb, "cache.ntds_settings_dn", settings_dn) != LDB_SUCCESS) {
- goto failed;
- }
+ /* note that we do not cache the DN here, as that would mean
+ * we could not handle server renames at runtime. Only
+ * provision sets up forced.ntds_settings_dn */
talloc_steal(ldb, settings_dn);
talloc_free(tmp_ctx);
diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
deleted file mode 100644
index f59919c..0000000
--- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- Unix SMB/CIFS mplementation.
-
- The module that handles the Domain Naming FSMO Role Owner
- checkings
-
- Copyright (C) Stefan Metzmacher 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "includes.h"
-#include "ldb_module.h"
-#include "dsdb/samdb/samdb.h"
-#include "librpc/gen_ndr/ndr_misc.h"
-#include "librpc/gen_ndr/ndr_drsuapi.h"
-#include "librpc/gen_ndr/ndr_drsblobs.h"
-#include "../lib/util/dlinklist.h"
-#include "dsdb/samdb/ldb_modules/util.h"
-
-static int naming_fsmo_init(struct ldb_module *module)
-{
- struct ldb_context *ldb;
- TALLOC_CTX *mem_ctx;
- struct ldb_dn *naming_dn;
- struct dsdb_naming_fsmo *naming_fsmo;
- struct ldb_result *naming_res;
- int ret;
- static const char *naming_attrs[] = {
- "fSMORoleOwner",
- NULL
- };
-
- ldb = ldb_module_get_ctx(module);
-
- mem_ctx = talloc_new(module);
- if (!mem_ctx) {
- return ldb_oom(ldb);
- }
-
- naming_dn = samdb_partitions_dn(ldb, mem_ctx);
- if (!naming_dn) {
- ldb_debug_set(ldb, LDB_DEBUG_FATAL,
- "naming_fsmo_init: unable to determine partitions dn");
- talloc_free(mem_ctx);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- naming_fsmo = talloc_zero(mem_ctx, struct dsdb_naming_fsmo);
- if (!naming_fsmo) {
- return ldb_oom(ldb);
- }
- ldb_module_set_private(module, naming_fsmo);
-
- ret = dsdb_module_search_dn(module, mem_ctx, &naming_res,
- naming_dn,
- naming_attrs,
- DSDB_FLAG_NEXT_MODULE, NULL);
- if (ret == LDB_ERR_NO_SUCH_OBJECT) {
- ldb_debug(ldb, LDB_DEBUG_TRACE,
- "naming_fsmo_init: no partitions dn present: (skip loading of naming contexts details)");
- talloc_free(mem_ctx);
- return ldb_next_init(module);
- }
-
- naming_fsmo->master_dn = ldb_msg_find_attr_as_dn(ldb, naming_fsmo, naming_res->msgs[0], "fSMORoleOwner");
- if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), naming_fsmo->master_dn) == 0) {
- naming_fsmo->we_are_master = true;
- } else {
- naming_fsmo->we_are_master = false;
- }
-
- if (ldb_set_opaque(ldb, "dsdb_naming_fsmo", naming_fsmo) != LDB_SUCCESS) {
- return ldb_oom(ldb);
- }
-
- talloc_steal(module, naming_fsmo);
-
- ldb_debug(ldb, LDB_DEBUG_TRACE,
- "naming_fsmo_init: we are master: %s\n",
- (naming_fsmo->we_are_master?"yes":"no"));
-
- talloc_free(mem_ctx);
- return ldb_next_init(module);
-}
-
-static const struct ldb_module_ops ldb_naming_fsmo_module_ops = {
- .name = "naming_fsmo",
- .init_context = naming_fsmo_init
-};
-
-int ldb_naming_fsmo_module_init(const char *version)
-{
- LDB_MODULE_CHECK_VERSION(version);
- return ldb_register_module(&ldb_naming_fsmo_module_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
deleted file mode 100644
index 68f1815..0000000
--- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- Unix SMB/CIFS mplementation.
-
- The module that handles the PDC FSMO Role Owner checkings
-
- Copyright (C) Stefan Metzmacher 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "includes.h"
-#include "ldb_module.h"
-#include "dsdb/samdb/samdb.h"
-#include "librpc/gen_ndr/ndr_misc.h"
-#include "librpc/gen_ndr/ndr_drsuapi.h"
-#include "librpc/gen_ndr/ndr_drsblobs.h"
-#include "../lib/util/dlinklist.h"
-#include "dsdb/samdb/ldb_modules/util.h"
-
-static int pdc_fsmo_init(struct ldb_module *module)
-{
- struct ldb_context *ldb;
- TALLOC_CTX *mem_ctx;
- struct ldb_dn *pdc_dn;
- struct dsdb_pdc_fsmo *pdc_fsmo;
- struct ldb_result *pdc_res;
- int ret;
- static const char *pdc_attrs[] = {
- "fSMORoleOwner",
- NULL
- };
-
- ldb = ldb_module_get_ctx(module);
-
- mem_ctx = talloc_new(module);
- if (!mem_ctx) {
- return ldb_oom(ldb);
- }
-
- pdc_dn = ldb_get_default_basedn(ldb);
- if (!pdc_dn) {
- ldb_debug_set(ldb, LDB_DEBUG_FATAL,
- "pdc_fsmo_init: could not determine default basedn");
- talloc_free(mem_ctx);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- pdc_fsmo = talloc_zero(mem_ctx, struct dsdb_pdc_fsmo);
- if (!pdc_fsmo) {
- return ldb_oom(ldb);
- }
- ldb_module_set_private(module, pdc_fsmo);
-
- ret = dsdb_module_search_dn(module, mem_ctx, &pdc_res,
- pdc_dn,
- pdc_attrs,
- DSDB_FLAG_NEXT_MODULE, NULL);
- if (ret == LDB_ERR_NO_SUCH_OBJECT) {
- ldb_debug(ldb, LDB_DEBUG_TRACE,
- "pdc_fsmo_init: no domain object present: (skip loading of domain details)");
- talloc_free(mem_ctx);
- return ldb_next_init(module);
- } else if (ret != LDB_SUCCESS) {
- ldb_debug_set(ldb, LDB_DEBUG_FATAL,
- "pdc_fsmo_init: failed to search the domain object: %d:%s: %s",
- ret, ldb_strerror(ret), ldb_errstring(ldb));
- talloc_free(mem_ctx);
- return ret;
- }
-
- pdc_fsmo->master_dn = ldb_msg_find_attr_as_dn(ldb, mem_ctx, pdc_res->msgs[0], "fSMORoleOwner");
- if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), pdc_fsmo->master_dn) == 0) {
- pdc_fsmo->we_are_master = true;
- } else {
- pdc_fsmo->we_are_master = false;
- }
-
- if (ldb_set_opaque(ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) {
- return ldb_oom(ldb);
- }
-
- talloc_steal(module, pdc_fsmo);
-
- ldb_debug(ldb, LDB_DEBUG_TRACE,
- "pdc_fsmo_init: we are master: %s\n",
- (pdc_fsmo->we_are_master?"yes":"no"));
-
- talloc_free(mem_ctx);
- return ldb_next_init(module);
-}
-
-static const struct ldb_module_ops ldb_pdc_fsmo_module_ops = {
- .name = "pdc_fsmo",
- .init_context = pdc_fsmo_init
-};
-
-int ldb_pdc_fsmo_module_init(const char *version)
-{
- LDB_MODULE_CHECK_VERSION(version);
- return ldb_register_module(&ldb_pdc_fsmo_module_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 2499e82..9813fe8 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -170,6 +170,37 @@ static int expand_dn_in_message(struct ldb_module *module, struct ldb_message *m
return LDB_SUCCESS;
}
+/*
+ see if we are master for a FSMO role
+ */
+static int dsdb_module_we_are_master(struct ldb_module *module, struct ldb_dn *dn, bool *master,
+ struct ldb_request *parent)
+{
+ const char *attrs[] = { "fSMORoleOwner", NULL };
+ TALLOC_CTX *tmp_ctx = talloc_new(parent);
+ struct ldb_result *res;
+ int ret;
+ struct ldb_dn *owner_dn;
+
+ ret = dsdb_module_search_dn(module, tmp_ctx, &res,
+ dn, attrs, DSDB_FLAG_NEXT_MODULE, parent);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return ret;
+ }
+
+ owner_dn = ldb_msg_find_attr_as_dn(ldb_module_get_ctx(module),
+ tmp_ctx, res->msgs[0], "fSMORoleOwner");
+ if (!owner_dn) {
+ *master = false;
+ talloc_free(tmp_ctx);
+ return LDB_SUCCESS;
+ }
+
+ *master = (ldb_dn_compare(owner_dn, samdb_ntds_settings_dn(ldb_module_get_ctx(module))) == 0);
+ talloc_free(tmp_ctx);
+ return LDB_SUCCESS;
+}
/*
add dynamically generated attributes to rootDSE result
@@ -186,12 +217,17 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
const char *dn_attrs[] = {
"configurationNamingContext",
"defaultNamingContext",
- "dsServiceName",
"rootDomainNamingContext",
"schemaNamingContext",
"serverName",
+ "validFSMOs",
+ NULL
+ };
+ const char *guid_attrs[] = {
+ "dsServiceName",
NULL
};
+ unsigned int i;
ldb = ldb_module_get_ctx(module);
schema = dsdb_get_schema(ldb, NULL);
@@ -258,7 +294,6 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
}
if (priv && do_attribute(attrs, "supportedControl")) {
- unsigned int i;
for (i = 0; i < priv->num_controls; i++) {
char *control = talloc_strdup(msg, priv->controls[i]);
if (!control) {
@@ -272,7 +307,6 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
}
if (priv && do_attribute(attrs, "namingContexts")) {
- unsigned int i;
for (i = 0; i < priv->num_partitions; i++) {
struct ldb_dn *dn = priv->partitions[i];
if (ldb_msg_add_steal_string(msg, "namingContexts",
@@ -285,7 +319,6 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
server_sasl = talloc_get_type(ldb_get_opaque(ldb, "supportedSASLMechanisms"),
char *);
if (server_sasl && do_attribute(attrs, "supportedSASLMechanisms")) {
- unsigned int i;
for (i = 0; server_sasl && server_sasl[i]; i++) {
char *sasl_name = talloc_strdup(msg, server_sasl[i]);
if (!sasl_name) {
@@ -346,38 +379,21 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
}
if (do_attribute_explicit(attrs, "validFSMOs")) {
- const struct dsdb_naming_fsmo *naming_fsmo;
- const struct dsdb_pdc_fsmo *pdc_fsmo;
- const char *dn_str;
-
- if (schema && schema->fsmo.we_are_master) {
- dn_str = ldb_dn_get_linearized(ldb_get_schema_basedn(ldb));
- if (dn_str && dn_str[0]) {
- if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != LDB_SUCCESS) {
- goto failed;
- }
- }
- }
+ struct ldb_dn *dns[3];
- naming_fsmo = talloc_get_type(ldb_get_opaque(ldb, "dsdb_naming_fsmo"),
- struct dsdb_naming_fsmo);
- if (naming_fsmo && naming_fsmo->we_are_master) {
- dn_str = ldb_dn_get_linearized(samdb_partitions_dn(ldb, msg));
- if (dn_str && dn_str[0]) {
- if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != LDB_SUCCESS) {
- goto failed;
- }
- }
- }
+ dns[0] = ldb_get_schema_basedn(ldb);
+ dns[1] = samdb_partitions_dn(ldb, msg);
+ dns[2] = ldb_get_default_basedn(ldb);
- pdc_fsmo = talloc_get_type(ldb_get_opaque(ldb, "dsdb_pdc_fsmo"),
- struct dsdb_pdc_fsmo);
- if (pdc_fsmo && pdc_fsmo->we_are_master) {
- dn_str = ldb_dn_get_linearized(ldb_get_default_basedn(ldb));
- if (dn_str && dn_str[0]) {
- if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != LDB_SUCCESS) {
- goto failed;
- }
+ for (i=0; i<3; i++) {
+ bool master;
+ int ret = dsdb_module_we_are_master(module, dns[i], &master, req);
+ if (ret != LDB_SUCCESS) {
+ goto failed;
+ }
+ if (master && ldb_msg_add_fmt(msg, "validFSMOs", "%s",
+ ldb_dn_get_linearized(dns[i])) != LDB_SUCCESS) {
+ goto failed;
}
}
}
@@ -426,7 +442,6 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
}
if (do_attribute_explicit(attrs, "tokenGroups")) {
- unsigned int i;
/* Obtain the user's session_info */
struct auth_session_info *session_info
= (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo");
@@ -446,11 +461,59 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
edn_control = ldb_request_get_control(req, LDB_CONTROL_EXTENDED_DN_OID);
+ /* convert any GUID attributes to be in the right form */
+ for (i=0; guid_attrs[i]; i++) {
+ struct ldb_result *res;
+ struct ldb_message_element *el;
+ struct ldb_dn *attr_dn;
+ const char *no_attrs[] = { NULL };
+ int ret;
+
+ if (!do_attribute(attrs, guid_attrs[i])) continue;
+
+ attr_dn = ldb_msg_find_attr_as_dn(ldb, req, msg, guid_attrs[i]);
+ if (attr_dn == NULL) {
+ continue;
+ }
+
+ ret = dsdb_module_search_dn(module, req, &res,
+ attr_dn, no_attrs,
+ DSDB_FLAG_NEXT_MODULE | DSDB_SEARCH_SHOW_EXTENDED_DN,
+ req);
+ if (ret != LDB_SUCCESS) {
+ return ldb_operr(ldb);
+ }
+
+ el = ldb_msg_find_element(msg, guid_attrs[i]);
+ if (el == NULL) {
+ return ldb_operr(ldb);
+ }
+
+ talloc_steal(el->values, res->msgs[0]->dn);
+ if (edn_control) {
+ struct ldb_extended_dn_control *edn;
+ int edn_type = 0;
+ edn = talloc_get_type(edn_control->data, struct ldb_extended_dn_control);
+ if (edn != NULL) {
+ edn_type = edn->type;
+ }
+ el->values[0].data = (uint8_t *)ldb_dn_get_extended_linearized(el->values,
+ res->msgs[0]->dn,
+ edn_type);
+ } else {
+ el->values[0].data = (uint8_t *)talloc_strdup(el->values,
+ ldb_dn_get_linearized(res->msgs[0]->dn));
+ }
+ if (el->values[0].data == NULL) {
+ return ldb_oom(ldb);
+ }
+ el->values[0].length = strlen((const char *)el->values[0].data);
--
Samba Shared Repository
More information about the samba-cvs
mailing list