Jelajahi Sumber

Ticket #47327 - error syncing group if group member user is not synced

Bug description: Windows Sync synchronizes member attributes
in a group entry if the member entry itself is synchronized.
The entries in the sync scope are basically to be synchronized.
But there is an exception such as a container in the scope is
not synchronized due to the objecttype constraints. Such an
unsync'ed entry could have users in it. Users are the target
of Windows Sync.  But since the parent container is not synch-
ronized, the users in the container are not, neither.  If a
group contains such special user as a member, synchronization
failed there and the other normal members are failed to get
synchronized.

Fix description: Windows Sync has a helper function
is_subject_of_agreement_remote, which checks if the entry is
in the scope to be synchronized.  This patch adds the check
if the checking entry's parent locally exists in the DS. If
it does not exist, it considers the entry is out of scope.
AD strictly checks if the entry exists prior to adding it
to a group entry as a member.  That is, a member to be added
is supposed to be in the server, as well as its parent is.
With this change, the AD user which is not synchronized to
the DS is just skipped to add to the group in the DS in the
same manner as an user out of scope is.

https://fedorahosted.org/389/ticket/47327

Reviewed by Rich (Thanks!!)
Noriko Hosoi 12 tahun lalu
induk
melakukan
9b0834c078
1 mengubah file dengan 31 tambahan dan 4 penghapusan
  1. 31 4
      ldap/servers/plugins/replication/windows_protocol_util.c

+ 31 - 4
ldap/servers/plugins/replication/windows_protocol_util.c

@@ -3858,8 +3858,11 @@ map_entry_dn_inbound_ext(Slapi_Entry *e, Slapi_DN **dn, const Repl_Agmt *ra, int
 															   windows_private_get_windows_subtree(ra));
 															   windows_private_get_windows_subtree(ra));
 				}
 				}
 			}
 			}
-			new_dn = slapi_sdn_new_dn_byval(new_dn_string);
-			PR_smprintf_free(new_dn_string);
+			/* 
+			 * new_dn_string is created by slapi_create_dn_string,
+			 * which is normalized. Thus, we can use _normdn_.
+			 */
+			new_dn = slapi_sdn_new_normdn_passin(new_dn_string);
 			slapi_ch_free_string(&container_str);
 			slapi_ch_free_string(&container_str);
 			/* Clear any earlier error */
 			/* Clear any earlier error */
 			retval = 0;
 			retval = 0;
@@ -3954,6 +3957,7 @@ is_subject_of_agreement_remote(Slapi_Entry *e, const Repl_Agmt *ra)
 	int retval = 0;
 	int retval = 0;
 	int is_in_subtree = 0;
 	int is_in_subtree = 0;
 	const Slapi_DN *agreement_subtree = NULL;
 	const Slapi_DN *agreement_subtree = NULL;
+	const Slapi_DN *sdn;
 	
 	
 	/* First test for the sync'ed subtree */
 	/* First test for the sync'ed subtree */
 	agreement_subtree = windows_private_get_windows_subtree(ra);
 	agreement_subtree = windows_private_get_windows_subtree(ra);
@@ -3961,10 +3965,33 @@ is_subject_of_agreement_remote(Slapi_Entry *e, const Repl_Agmt *ra)
 	{
 	{
 		goto error;
 		goto error;
 	}
 	}
-	is_in_subtree = slapi_sdn_scope_test(slapi_entry_get_sdn_const(e), agreement_subtree, LDAP_SCOPE_SUBTREE);
+	sdn = slapi_entry_get_sdn_const(e);
+	is_in_subtree = slapi_sdn_scope_test(sdn, agreement_subtree, LDAP_SCOPE_SUBTREE);
 	if (is_in_subtree) 
 	if (is_in_subtree) 
 	{
 	{
-		retval = 1;
+		Slapi_DN psdn = {0};
+		Slapi_Entry *pentry = NULL;
+		/*
+		 * Check whether the parent of the entry exists or not.
+		 * If it does not, treat the entry e is out of scope.
+		 * For instance, agreement_subtree is cn=USER,<SUFFIX>
+		 * cn=container,cn=USER,<SUFFIX> is not synchronized.
+		 * If 'e' is uid=test,cn=container,cn=USER,<SUFFIX>,
+		 * the entry is not synchronized, either.  We treat
+		 * 'e' as out of scope.
+		 */
+		slapi_sdn_get_parent(sdn, &psdn);
+		if (0 == slapi_sdn_compare(&psdn, agreement_subtree)) {
+			retval = 1;
+		} else {
+			/* If parent entry is not local, the entry is out of scope */
+			int rc = windows_get_local_entry(&psdn, &pentry);
+			if ((0 == rc) && pentry) {
+				retval = 1;
+				slapi_entry_free(pentry);
+			}
+		}
+		slapi_sdn_done(&psdn);
 	}
 	}
 error:
 error:
 	return retval;
 	return retval;