summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules/dirsync.c
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2011-07-08 02:04:52 +0400
committerAndrew Tridgell <tridge@samba.org>2011-07-11 14:32:45 +1000
commit4a4c748d2b3071ad7cd06b96cb0279a89c3ec6d0 (patch)
tree10c5aabc0ee2f0476d35e0a49cf87684c1d13cb3 /source4/dsdb/samdb/ldb_modules/dirsync.c
parent74530d6453451d7a7ad08a11e37ea8b4672fc4ab (diff)
downloadsamba-4a4c748d2b3071ad7cd06b96cb0279a89c3ec6d0.tar.gz
samba-4a4c748d2b3071ad7cd06b96cb0279a89c3ec6d0.tar.bz2
samba-4a4c748d2b3071ad7cd06b96cb0279a89c3ec6d0.zip
s4-dirsync: do not return linked attribute if the target object is no more
Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules/dirsync.c')
-rw-r--r--source4/dsdb/samdb/ldb_modules/dirsync.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/dirsync.c b/source4/dsdb/samdb/ldb_modules/dirsync.c
index 64c5047798..7ed1ed3943 100644
--- a/source4/dsdb/samdb/ldb_modules/dirsync.c
+++ b/source4/dsdb/samdb/ldb_modules/dirsync.c
@@ -428,10 +428,17 @@ skip:
uint32_t tmp_usn2 = 0;
struct GUID invocation_id = GUID_zero();
struct dsdb_dn *dn = dsdb_dn_parse(msg, ldb, &el->values[k], attr->syntax->ldap_oid);
+ struct ldb_dn *copydn;
if (dn == NULL) {
ldb_set_errstring(ldb, "Cannot parse DN");
return ldb_module_done(dsc->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
}
+
+ copydn = ldb_dn_copy(msg, dn->dn);
+ if (copydn == NULL) {
+ ldb_oom(ldb);
+ }
+
status = dsdb_get_extended_dn_uint32(dn->dn, &tmp_usn, "RMD_LOCAL_USN");
if (!NT_STATUS_IS_OK(status)) {
talloc_free(dn);
@@ -504,6 +511,28 @@ skip:
if (dsc->linkIncrVal == true) {
struct ldb_message_element *tmpel;
if (flags & DSDB_RMD_FLAG_DELETED) {
+ /* We have to check that the inactive link still point to an existing object */
+ struct GUID guid;
+ struct ldb_dn *tdn;
+ int ret;
+
+ status = dsdb_get_extended_dn_guid(copydn, &guid, "GUID");
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,(__location__ " Unable to extract GUID in linked attribute '%s' in '%s'\n",
+ el->name, ldb_dn_get_linearized(copydn)));
+ return ldb_operr(ldb);
+ }
+ ret = dsdb_find_dn_by_guid(ldb, newmsg, &guid, &tdn);
+ if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+ DEBUG(2, (" Search of guid %s returned 0 objects, skipping it !\n",
+ GUID_string(newmsg, &guid)));
+ continue;
+ } else if (ret != LDB_SUCCESS) {
+ DEBUG(0, (__location__ " Search of guid %s failed with error code %d\n",
+ GUID_string(newmsg, &guid),
+ ret));
+ continue;
+ }
tmpel = el_incr_del;
} else {
tmpel = el_incr_add;