0
Fixed

Reflection fails with "An item with the same key has already been added"

Matthew Woolnough 8 years ago updated by anonymous 8 years ago 11

Accountname is a DistinguishedName attribute & is used in Sharepoint connector as the Key and also as the DN in adapter. 

Image 4174


No key duplication errors are being seen. 

Data can be imported without error with Adapter disabled.  

When 'Generate Changes' is performed the error below is thrown. Is this the correct way to use a DN attribute as a DN? Not sure if this is a bug or misconfiguration.

<AdapterConfiguration AdapterId="4e96758c-06c5-44dd-9f32-557b3e75d16f" AdapterName="SharePoint Profiles" containerName="SPUsers" enabled="false" BaseConnectorId="770d9450-dcc8-41c9-b0b4-bc2d46fdc3ae" class="person">
      <dn template="[AccountName]" />
      <Groups />
      <adapterEntityTransformationFactory name="Sequential">
        <adapter name="Move" key="1bec7d3a-9384-49b6-ad4b-8266e5a286b0">
          <Extended>
            <columnMappings>
              <columnMapping SourceAttribute="UserProfile_GUID" TargetAttribute="UserProfileGUID" />
            </columnMappings>
          </Extended>
        </adapter>
      </adapterEntityTransformationFactory>
    </AdapterConfiguration>


20170605,07:13:28,UNIFY Identity Broker,Adapter,Error,"Request to reflect change entities of the adapter.
Request to reflect change entities of the SharePoint Profiles (4e96758c-06c5-44dd-9f32-557b3e75d16f) adapter errored with message: An item with the same key has already been added.. Duration: 00:00:00.5937686
Error details:
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Unify.Product.IdentityBroker.Adapter.ConvertPageAndUpdateContainers(IEntity[] entities, Boolean updateContainers)
   at Unify.Product.IdentityBroker.Adapter.ReflectChangesInner()
   at Unify.Product.IdentityBroker.Adapter.ReflectChanges()
   at Unify.Product.IdentityBroker.AdapterAuditingDecorator.ReflectChanges()
   at Unify.Product.IdentityBroker.AdapterNotifierDecorator.ReflectChanges()
   at Unify.Product.IdentityBroker.ReflectAdapterOnChangeDueJob.<RunBase>b__9_0(IOperationalAdapter adapter)",Normal


Answer

+1
Answer

Hi Matt,

I have identified the cause of the issue, and the following Unify.Framework.IO.LDIF.dll, when placed into the Services directory, should resolve this. This patch will be included in future versions of Identity Broker v5.1 and up.

Under review

The failing code could be one of two things:

  1. Duplicate entity id's
  2. Duplicate container dn's

We can rule them out with the following:

1.

SELECT EntityId, COUNT(*)
FROM Entity
WHERE PartitionId = 'connector partition id'
GROUP BY EntityId
HAVING COUNT(*) > 1

2.

SELECT DistinguishedName, COUNT(*)
FROM Container
GROUP BY DistinguishedName
HAVING COUNT(*) > 1


One (or both) of those should bring something back as that's what's being checked in this method. However, it shouldn't actually be possible.

Neither of these queries returned any rows. 

That's interesting, as that's the two possibilities.

I can give some additional logging shortly if required. However, we should rule out the data first. Try using the Identity Broker id for the dn and see if it gets further.

Thanks.

Appears to have completed successfully.


Request to reflect change entities of the SharePoint Profiles (4e96758c-06c5-44dd-9f32-557b3e75d16f) adapter started.",Verbose
20170605,22:31:03,UNIFY Identity Broker,Changes register engine,Information,"Request to retrieve changes register context.
Request to retrieve changes register context started.",Verbose
20170605,22:31:03,UNIFY Identity Broker,Changes register engine,Information,"Request to retrieve changes register context.
Request to retrieve changes register context completed. Duration: 00:00:00",Verbose
20170605,22:31:03,UNIFY Identity Broker,Change log engine,Information,"Request to retrieve change log context.
Request to retrieve change log context started.",Verbose
20170605,22:31:03,UNIFY Identity Broker,Change log engine,Information,"Request to retrieve change log context.
Request to retrieve change log context completed. Duration: 00:00:00",Verbose
20170605,22:31:03,UNIFY Identity Broker,Adapter,Information,"Request to reflect change entities of the adapter.
Request to reflect change entities of the SharePoint Profiles (4e96758c-06c5-44dd-9f32-557b3e75d16f) adapter completed with 0 adds, 0 updates and 0 deletes across 0 pages. Duration: 00:00:00.0156221",Verbose

Is the adapter now populated with the correct number of entities?

I switched it back to how it's supposed to be configured and the error has returned. 



20170606,01:51:08,UNIFY Identity Broker,Adapter,Error,"Adapter
Adapter 4e96758c-06c5-44dd-9f32-557b3e75d16f page errored on page reflection. Duration: 00:00:00.8593748. Error: System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Unify.Product.IdentityBroker.Adapter.ConvertPageAndUpdateContainers(IEntity[] entities, Boolean updateContainers)
   at Unify.Product.IdentityBroker.Adapter.ReflectChangesInner()
   at Unify.Product.IdentityBroker.Adapter.ReflectChanges()
   at Unify.Product.IdentityBroker.AdapterAuditingDecorator.ReflectChanges()
   at Unify.Product.IdentityBroker.AdapterNotifierDecorator.ReflectChanges()
   at Unify.Product.IdentityBroker.ReflectAdapterOnChangeDueJob.<RunBase>b__9_0(IOperationalAdapter adapter).
Error details:

What do you mean "how it's supposed to be configured"? When it was working was that with a different configuration? What's wrong with using the different configuration, is there a particular reason that you need the dn as the account name?

I'm performing a migration.  Not sure if it has to be configured this way. I don't understand everything that's happening in this solution as it's using Codeless framework which I know next to nothing about.  Using the AccountName as the DN is how it was configured and I am replicating that as closely as possible as I can. 


+1
Answer

Hi Matt,

I have identified the cause of the issue, and the following Unify.Framework.IO.LDIF.dll, when placed into the Services directory, should resolve this. This patch will be included in future versions of Identity Broker v5.1 and up.