attrs[1] = NULL;
for (i=0; i<el->num_values; i++) {
+ NTSTATUS status;
struct dsdb_dn *dsdb_dn;
unsigned int j;
int ret;
+ struct GUID guid;
struct ldb_result *res;
struct ldb_message *msg;
struct ldb_message_element *el2;
return LDB_ERR_INVALID_DN_SYNTAX;
}
- ret = dsdb_module_search_dn(module, tmp_ctx, &res, dsdb_dn->dn,
- attrs,
- DSDB_SEARCH_SHOW_DELETED |
- DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT |
- DSDB_SEARCH_REVEAL_INTERNALS);
- if (ret != LDB_SUCCESS) {
+ status = dsdb_get_extended_dn_guid(dsdb_dn->dn, &guid, "GUID");
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ ret = dsdb_module_search_dn(module, tmp_ctx, &res, dsdb_dn->dn,
+ attrs,
+ DSDB_SEARCH_SHOW_DELETED |
+ DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT |
+ DSDB_SEARCH_REVEAL_INTERNALS);
+ } else if (NT_STATUS_IS_OK(status)) {
+ ret = dsdb_module_search(module, tmp_ctx, &res, NULL,
+ LDB_SCOPE_SUBTREE, attrs,
+ DSDB_SEARCH_SHOW_DELETED |
+ DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT |
+ DSDB_SEARCH_REVEAL_INTERNALS | DSDB_SEARCH_ONE_ONLY,
+ "objectGUID=%s", GUID_string(tmp_ctx, &guid));
+ } else {
+ ldb_asprintf_errstring(ldb, "Linked attribute %s->%s between %s and %s - failed to parse GUID in DN %s",
+ el->name, target->lDAPDisplayName,
+ ldb_dn_get_linearized(old_dn),
+ ldb_dn_get_linearized(dsdb_dn->dn),
+ ldb_dn_get_extended_linearized(tmp_ctx, dsdb_dn->dn, 1));
+ talloc_free(tmp_ctx);
+ return LDB_ERR_INVALID_DN_SYNTAX;
+ }
+ if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+ /* Perhaps this is a link to an object outside
+ * our server - we don't need to update the
+ * other end, as it's not in our DB. */
+ DEBUG(2,(__location__ ": WARNING: Failed to find target DN %s for linked attribute update\n",
+ ldb_dn_get_extended_linearized(tmp_ctx, dsdb_dn->dn, 1)));
+ continue;
+ } else if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb, "Linked attribute %s->%s between %s and %s - remote not found - %s",
el->name, target->lDAPDisplayName,
ldb_dn_get_linearized(old_dn),