s4-drs: When comparing DN, check the DN itself and its extra bits if present
authorMatthieu Patou <mat@matws.net>
Wed, 3 Oct 2012 08:35:13 +0000 (01:35 -0700)
committerMatthieu Patou <mat@matws.net>
Sun, 18 May 2014 04:51:15 +0000 (21:51 -0700)
For DN+String or DN+Binary the extra makes the difference so it's not sufficient
to compare just the DN, the extra has to match otherwise it's a different "DN".
Which means that if you had B:00000001:DC=Foo and you have a replace with just
B:00000002:DC=Foo you have to mark the first DN as deleted and the new one as created
Before we would have just increased the version on the DN (and updated the USNs).

I discovered this while replicating the configuration NC from a Windows DC that has just been
promoted I noticed that for the attribute msDS-HasInstantiatedNCs we had 2 entries
for each domain related NC (forest and domain):
* One to delete the previous DN+Binary
* One to create the new one

For instance in the following dump, attribute 0x906AD has one value
deleted for DC=DomainDnsZones,DC=samba,DC=corp (entry #1) and then
added (#3). The same for the value DC=ForestDnsZones,DC=samba,DC=corp
that is first deleted (entry #2) and then added (#5)

                  nc_linked_attributes_count: 0x00000000 (0)
                    linked_attributes_count  : 0x0000000a (10)
                    linked_attributes        : *
                        linked_attributes: ARRAY(10)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : UNKNOWN_ENUM_VALUE (0x906AD)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x00000088 (136)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=136
[0000] 7E 00 00 00 00 00 00 00   83 48 D5 7E FF 93 C9 4D   ~....... .H.~...M
[0010] 8E 9C 64 9D 4D 46 7D 21   00 00 00 00 00 00 00 00   ..d.MF}! ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 22 00 00 00   44 00 43 00 3D 00 44 00   ...."... D.C.=.D.
[0040] 6F 00 6D 00 61 00 69 00   6E 00 44 00 6E 00 73 00   o.m.a.i. n.D.n.s.
[0050] 5A 00 6F 00 6E 00 65 00   73 00 2C 00 44 00 43 00   Z.o.n.e. s.,.D.C.
[0060] 3D 00 73 00 61 00 6D 00   62 00 61 00 2C 00 44 00   =.s.a.m. b.a.,.D.
[0070] 43 00 3D 00 63 00 6F 00   72 00 70 00 00 00 00 00   C.=.c.o. r.p.....
[0080] 08 00 00 00 00 00 00 1D                            ........
                                flags                    : 0x00000000 (0)
                                       0: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:29:12 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000002 (2)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x00000000000020be (8382)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : UNKNOWN_ENUM_VALUE (0x906AD)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x00000088 (136)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=136
[0000] 7E 00 00 00 00 00 00 00   C1 D0 CF 56 4C 59 FF 41   ~....... ...VLY.A
[0010] BF 9A 40 27 EC CB D7 B4   00 00 00 00 00 00 00 00   ..@'.... ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 22 00 00 00   44 00 43 00 3D 00 46 00   ...."... D.C.=.F.
[0040] 6F 00 72 00 65 00 73 00   74 00 44 00 6E 00 73 00   o.r.e.s. t.D.n.s.
[0050] 5A 00 6F 00 6E 00 65 00   73 00 2C 00 44 00 43 00   Z.o.n.e. s.,.D.C.
[0060] 3D 00 73 00 61 00 6D 00   62 00 61 00 2C 00 44 00   =.s.a.m. b.a.,.D.
[0070] 43 00 3D 00 63 00 6F 00   72 00 70 00 00 00 00 00   C.=.c.o. r.p.....
[0080] 08 00 00 00 00 00 00 1D                            ........
                                flags                    : 0x00000000 (0)
                                       0: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:29:12 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000002 (2)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x00000000000020e8 (8424)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : UNKNOWN_ENUM_VALUE (0x906AD)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x00000088 (136)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=136
[0000] 7E 00 00 00 00 00 00 00   83 48 D5 7E FF 93 C9 4D   ~....... .H.~...M
[0010] 8E 9C 64 9D 4D 46 7D 21   00 00 00 00 00 00 00 00   ..d.MF}! ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 22 00 00 00   44 00 43 00 3D 00 44 00   ...."... D.C.=.D.
[0040] 6F 00 6D 00 61 00 69 00   6E 00 44 00 6E 00 73 00   o.m.a.i. n.D.n.s.
[0050] 5A 00 6F 00 6E 00 65 00   73 00 2C 00 44 00 43 00   Z.o.n.e. s.,.D.C.
[0060] 3D 00 73 00 61 00 6D 00   62 00 61 00 2C 00 44 00   =.s.a.m. b.a.,.D.
[0070] 43 00 3D 00 63 00 6F 00   72 00 70 00 00 00 00 00   C.=.c.o. r.p.....
[0080] 08 00 00 00 00 00 00 0D                            ........
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:29:12 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000001 (1)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x00000000000020c2 (8386)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : UNKNOWN_ENUM_VALUE (0x906AD)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x00000064 (100)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=100
[0000] 5A 00 00 00 18 00 00 00   84 74 F0 70 C8 DC 3F 46   Z....... .t.p..?F
[0010] 93 97 53 54 B4 48 69 39   01 04 00 00 00 00 00 05   ..ST.Hi9 ........
[0020] 15 00 00 00 39 E2 C6 13   FB 0F 59 86 29 81 15 55   ....9... ..Y.)..U
[0030] 00 00 00 00 10 00 00 00   44 00 43 00 3D 00 73 00   ........ D.C.=.s.
[0040] 61 00 6D 00 62 00 61 00   2C 00 44 00 43 00 3D 00   a.m.b.a. ,.D.C.=.
[0050] 63 00 6F 00 72 00 70 00   00 00 00 00 08 00 00 00   c.o.r.p. ........
[0060] 00 00 00 05                                       ....
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:29:12 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000001 (1)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x0000000000002082 (8322)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : UNKNOWN_ENUM_VALUE (0x906AD)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x00000088 (136)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=136
[0000] 7E 00 00 00 00 00 00 00   C1 D0 CF 56 4C 59 FF 41   ~....... ...VLY.A
[0010] BF 9A 40 27 EC CB D7 B4   00 00 00 00 00 00 00 00   ..@'.... ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 22 00 00 00   44 00 43 00 3D 00 46 00   ...."... D.C.=.F.
[0040] 6F 00 72 00 65 00 73 00   74 00 44 00 6E 00 73 00   o.r.e.s. t.D.n.s.
[0050] 5A 00 6F 00 6E 00 65 00   73 00 2C 00 44 00 43 00   Z.o.n.e. s.,.D.C.
[0060] 3D 00 73 00 61 00 6D 00   62 00 61 00 2C 00 44 00   =.s.a.m. b.a.,.D.
[0070] 43 00 3D 00 63 00 6F 00   72 00 70 00 00 00 00 00   C.=.c.o. r.p.....
[0080] 08 00 00 00 00 00 00 0D                            ........
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:29:12 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000001 (1)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x00000000000020ec (8428)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : DRSUAPI_ATTID_msDS_hasMasterNCs (0x9072C)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x0000007e (126)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=126
[0000] 7E 00 00 00 00 00 00 00   83 48 D5 7E FF 93 C9 4D   ~....... .H.~...M
[0010] 8E 9C 64 9D 4D 46 7D 21   00 00 00 00 00 00 00 00   ..d.MF}! ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 22 00 00 00   44 00 43 00 3D 00 44 00   ...."... D.C.=.D.
[0040] 6F 00 6D 00 61 00 69 00   6E 00 44 00 6E 00 73 00   o.m.a.i. n.D.n.s.
[0050] 5A 00 6F 00 6E 00 65 00   73 00 2C 00 44 00 43 00   Z.o.n.e. s.,.D.C.
[0060] 3D 00 73 00 61 00 6D 00   62 00 61 00 2C 00 44 00   =.s.a.m. b.a.,.D.
[0070] 43 00 3D 00 63 00 6F 00   72 00 70 00 00 00        C.=.c.o. r.p...
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:29:12 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000003 (3)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x00000000000020c1 (8385)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : DRSUAPI_ATTID_msDS_hasMasterNCs (0x9072C)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x0000005a (90)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=90
[0000] 5A 00 00 00 18 00 00 00   84 74 F0 70 C8 DC 3F 46   Z....... .t.p..?F
[0010] 93 97 53 54 B4 48 69 39   01 04 00 00 00 00 00 05   ..ST.Hi9 ........
[0020] 15 00 00 00 39 E2 C6 13   FB 0F 59 86 29 81 15 55   ....9... ..Y.)..U
[0030] 00 00 00 00 10 00 00 00   44 00 43 00 3D 00 73 00   ........ D.C.=.s.
[0040] 61 00 6D 00 62 00 61 00   2C 00 44 00 43 00 3D 00   a.m.b.a. ,.D.C.=.
[0050] 63 00 6F 00 72 00 70 00   00 00                    c.o.r.p. ..
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:28:48 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000002 (2)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x0000000000002081 (8321)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 60b2cf44-9b15-408d-bdd0-65b9514e7114
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : DRSUAPI_ATTID_msDS_hasMasterNCs (0x9072C)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x0000007e (126)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=126
[0000] 7E 00 00 00 00 00 00 00   C1 D0 CF 56 4C 59 FF 41   ~....... ...VLY.A
[0010] BF 9A 40 27 EC CB D7 B4   00 00 00 00 00 00 00 00   ..@'.... ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 22 00 00 00   44 00 43 00 3D 00 46 00   ...."... D.C.=.F.
[0040] 6F 00 72 00 65 00 73 00   74 00 44 00 6E 00 73 00   o.r.e.s. t.D.n.s.
[0050] 5A 00 6F 00 6E 00 65 00   73 00 2C 00 44 00 43 00   Z.o.n.e. s.,.D.C.
[0060] 3D 00 73 00 61 00 6D 00   62 00 61 00 2C 00 44 00   =.s.a.m. b.a.,.D.
[0070] 43 00 3D 00 63 00 6F 00   72 00 70 00 00 00        C.=.c.o. r.p...
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:29:12 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000003 (3)
                                    originating_change_time  : Sat Sep 29 11:29:12 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x00000000000020eb (8427)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : e60a70b2-c6aa-42e5-b528-7c36be5e59a2
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : UNKNOWN_ENUM_VALUE (0x9067D)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x00000116 (278)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=278
[0000] 16 01 00 00 00 00 00 00   44 CF B2 60 15 9B 8D 40   ........ D..`...@
[0010] BD D0 65 B9 51 4E 71 14   00 00 00 00 00 00 00 00   ..e.QNq. ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 6E 00 00 00   43 00 4E 00 3D 00 4E 00   ....n... C.N.=.N.
[0040] 54 00 44 00 53 00 20 00   53 00 65 00 74 00 74 00   T.D.S. . S.e.t.t.
[0050] 69 00 6E 00 67 00 73 00   2C 00 43 00 4E 00 3D 00   i.n.g.s. ,.C.N.=.
[0060] 53 00 31 00 2D 00 57 00   32 00 4B 00 38 00 52 00   S.1.-.W. 2.K.8.R.
[0070] 32 00 2C 00 43 00 4E 00   3D 00 53 00 65 00 72 00   2.,.C.N. =.S.e.r.
[0080] 76 00 65 00 72 00 73 00   2C 00 43 00 4E 00 3D 00   v.e.r.s. ,.C.N.=.
[0090] 44 00 65 00 66 00 61 00   75 00 6C 00 74 00 2D 00   D.e.f.a. u.l.t.-.
[00A0] 46 00 69 00 72 00 73 00   74 00 2D 00 53 00 69 00   F.i.r.s. t.-.S.i.
[00B0] 74 00 65 00 2D 00 4E 00   61 00 6D 00 65 00 2C 00   t.e.-.N. a.m.e.,.
[00C0] 43 00 4E 00 3D 00 53 00   69 00 74 00 65 00 73 00   C.N.=.S. i.t.e.s.
[00D0] 2C 00 43 00 4E 00 3D 00   43 00 6F 00 6E 00 66 00   ,.C.N.=. C.o.n.f.
[00E0] 69 00 67 00 75 00 72 00   61 00 74 00 69 00 6F 00   i.g.u.r. a.t.i.o.
[00F0] 6E 00 2C 00 44 00 43 00   3D 00 73 00 61 00 6D 00   n.,.D.C. =.s.a.m.
[0100] 62 00 61 00 2C 00 44 00   43 00 3D 00 63 00 6F 00   b.a.,.D. C.=.c.o.
[0110] 72 00 70 00 00 00                                 r.p...
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:28:57 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000001 (1)
                                    originating_change_time  : Sat Sep 29 11:28:57 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x0000000000001e12 (7698)
                            linked_attributes: struct drsuapi_DsReplicaLinkedAttribute
                                identifier               : *
                                    identifier: struct drsuapi_DsReplicaObjectIdentifier
                                        __ndr_size               : 0x0000003a (58)
                                        __ndr_size_sid           : 0x00000000 (0)
                                        guid                     : 80a740d8-f63e-4b37-a5c4-19dd4a9123ef
                                        sid                      : S-0-0
                                        __ndr_size_dn            : 0x00000000 (0)
                                        dn                       : ''
                                attid                    : UNKNOWN_ENUM_VALUE (0x9067D)
                                value: struct drsuapi_DsAttributeValue
                                    __ndr_size               : 0x00000116 (278)
                                    blob                     : *
                                        blob                     : DATA_BLOB length=278
[0000] 16 01 00 00 00 00 00 00   44 CF B2 60 15 9B 8D 40   ........ D..`...@
[0010] BD D0 65 B9 51 4E 71 14   00 00 00 00 00 00 00 00   ..e.QNq. ........
[0020] 00 00 00 00 00 00 00 00   00 00 00 00 00 00 00 00   ........ ........
[0030] 00 00 00 00 6E 00 00 00   43 00 4E 00 3D 00 4E 00   ....n... C.N.=.N.
[0040] 54 00 44 00 53 00 20 00   53 00 65 00 74 00 74 00   T.D.S. . S.e.t.t.
[0050] 69 00 6E 00 67 00 73 00   2C 00 43 00 4E 00 3D 00   i.n.g.s. ,.C.N.=.
[0060] 53 00 31 00 2D 00 57 00   32 00 4B 00 38 00 52 00   S.1.-.W. 2.K.8.R.
[0070] 32 00 2C 00 43 00 4E 00   3D 00 53 00 65 00 72 00   2.,.C.N. =.S.e.r.
[0080] 76 00 65 00 72 00 73 00   2C 00 43 00 4E 00 3D 00   v.e.r.s. ,.C.N.=.
[0090] 44 00 65 00 66 00 61 00   75 00 6C 00 74 00 2D 00   D.e.f.a. u.l.t.-.
[00A0] 46 00 69 00 72 00 73 00   74 00 2D 00 53 00 69 00   F.i.r.s. t.-.S.i.
[00B0] 74 00 65 00 2D 00 4E 00   61 00 6D 00 65 00 2C 00   t.e.-.N. a.m.e.,.
[00C0] 43 00 4E 00 3D 00 53 00   69 00 74 00 65 00 73 00   C.N.=.S. i.t.e.s.
[00D0] 2C 00 43 00 4E 00 3D 00   43 00 6F 00 6E 00 66 00   ,.C.N.=. C.o.n.f.
[00E0] 69 00 67 00 75 00 72 00   61 00 74 00 69 00 6F 00   i.g.u.r. a.t.i.o.
[00F0] 6E 00 2C 00 44 00 43 00   3D 00 73 00 61 00 6D 00   n.,.D.C. =.s.a.m.
[0100] 62 00 61 00 2C 00 44 00   43 00 3D 00 63 00 6F 00   b.a.,.D. C.=.c.o.
[0110] 72 00 70 00 00 00                                 r.p...
                                flags                    : 0x00000001 (1)
                                       1: DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE
                                originating_add_time     : Sat Sep 29 11:28:57 PM 2012 PDT
                                meta_data: struct drsuapi_DsReplicaMetaData
                                    version                  : 0x00000001 (1)
                                    originating_change_time  : Sat Sep 29 11:28:57 PM 2012 PDT
                                    originating_invocation_id: 6dae53b2-4451-43fa-aead-92beb46962f3
                                    originating_usn          : 0x0000000000001e10 (7696)
                    drs_error                : WERR_OK
            result                   : WERR_OK
dump OK

Change-Id: I430c799c917f7cbf67254ffa010c372d796e022e
Signed-off-by: Matthieu Patou <mat@matws.net>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 83dabdfdf3b1195e9174a14e4b44240a197fbef3..ad703286eecf69008e032e1a4fe773480e6651d1 100644 (file)
@@ -1613,7 +1613,8 @@ static int parsed_dn_compare(struct parsed_dn *pdn1, struct parsed_dn *pdn2)
 
 static struct parsed_dn *parsed_dn_find(struct parsed_dn *pdn,
                                        unsigned int count, struct GUID *guid,
-                                       struct ldb_dn *dn)
+                                       struct ldb_dn *dn,
+                                       DATA_BLOB extra)
 {
        struct parsed_dn *ret;
        unsigned int i;
@@ -1629,6 +1630,18 @@ static struct parsed_dn *parsed_dn_find(struct parsed_dn *pdn,
                return NULL;
        }
        BINARY_ARRAY_SEARCH(pdn, count, guid, guid, GUID_compare, ret);
+       if (extra.length && ret) {
+               /*
+                * Check the content of the extra it's a match only
+                * if the dn match but also the extra.
+                */
+               if (ret->dsdb_dn->extra_part.length != extra.length) {
+                       return NULL;
+               }
+               if (memcmp(ret->dsdb_dn->extra_part.data, extra.data, extra.length) != 0) {
+                       return NULL;
+               }
+       }
        return ret;
 }
 
@@ -1979,7 +1992,9 @@ static int replmd_modify_la_add(struct ldb_module *module,
 
        /* for each new value, see if it exists already with the same GUID */
        for (i=0; i<el->num_values; i++) {
-               struct parsed_dn *p = parsed_dn_find(old_dns, old_num_values, dns[i].guid, NULL);
+               struct parsed_dn *p = parsed_dn_find(old_dns, old_num_values,
+                                                    dns[i].guid, NULL,
+                                                    dns[i].dsdb_dn->extra_part);
                if (p == NULL) {
                        /* this is a new linked attribute value */
                        new_values = talloc_realloc(tmp_ctx, new_values, struct ldb_val, num_new_values+1);
@@ -2118,7 +2133,8 @@ static int replmd_modify_la_delete(struct ldb_module *module,
                struct parsed_dn *p2;
                uint32_t rmd_flags;
 
-               p2 = parsed_dn_find(old_dns, old_el->num_values, p->guid, NULL);
+               p2 = parsed_dn_find(old_dns, old_el->num_values, p->guid, NULL,
+                                   p->dsdb_dn->extra_part);
                if (!p2) {
                        ldb_asprintf_errstring(ldb, "Attribute %s doesn't exist for target GUID %s",
                                               el->name, GUID_string(tmp_ctx, p->guid));
@@ -2147,7 +2163,9 @@ static int replmd_modify_la_delete(struct ldb_module *module,
                struct parsed_dn *p = &old_dns[i];
                uint32_t rmd_flags;
 
-               if (el->num_values && parsed_dn_find(dns, el->num_values, p->guid, NULL) == NULL) {
+               if (el->num_values && parsed_dn_find(dns, el->num_values,
+                                                    p->guid, NULL,
+                                                    p->dsdb_dn->extra_part) == NULL) {
                        continue;
                }
 
@@ -2250,7 +2268,8 @@ static int replmd_modify_la_replace(struct ldb_module *module,
                        return ret;
                }
 
-               p = parsed_dn_find(dns, el->num_values, old_p->guid, NULL);
+               p = parsed_dn_find(dns, el->num_values, old_p->guid, NULL,
+                                  old_p->dsdb_dn->extra_part);
                if (p) {
                        /* we don't delete it if we are re-adding it */
                        continue;
@@ -2272,7 +2291,8 @@ static int replmd_modify_la_replace(struct ldb_module *module,
 
                if (old_dns &&
                    (old_p = parsed_dn_find(old_dns,
-                                           old_num_values, p->guid, NULL)) != NULL) {
+                                           old_num_values, p->guid, NULL,
+                                           p->dsdb_dn->extra_part)) != NULL) {
                        /* update in place */
                        ret = replmd_update_la_val(old_el->values, old_p->v, p->dsdb_dn,
                                                   old_p->dsdb_dn, invocation_id,
@@ -5585,7 +5605,8 @@ linked_attributes[0]:
        }
 
        /* see if this link already exists */
-       pdn = parsed_dn_find(pdn_list, old_el->num_values, &guid, dsdb_dn->dn);
+       pdn = parsed_dn_find(pdn_list, old_el->num_values, &guid, dsdb_dn->dn,
+                            dsdb_dn->extra_part);
        if (pdn != NULL) {
                /* see if this update is newer than what we have already */
                struct GUID invocation_id = GUID_zero();