Q208051: Error: "Item has already been added. Key in dictionary..." on importing DM inventory

Symptoms

When importing inventories into DM they end up in BadLogs and the logs show the following error:
EXCEPTION:
--------------------
System.ArgumentException: Item has already been added. Key in dictionary: 'myDomain'&ampnbsp Key being added: 'myDomain'

   at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)

   at System.Collections.Hashtable.Add(Object key, Object value)

   at ManageSoft.Directory.Impl.DirectoryBinder.CacheAllDomains(IManageSoftDatabaseLayer databaseLayer)

   at ManageSoft.Directory.Impl.DirectoryBinder.BindToComputerAndUser(IManageSoftDatabaseLayer databaseLayer, String computerName, String computerDomain, String computerFlatDomain, DirectoryEntry computerObject, String userName, String userDomain, Boolean useUniqueNames, Int32& computerID, Int32& computerOUID, Int32& userID, Int32& userOUID)

   at ManageSoft.Directory.Impl.DirectoryImpl.BindToComputerAndUser(String computerName, String computerDomain, String computerFlatDomain, String userName, String userDomain, Boolean useUniqueNames, Int32& computerID, Int32& computerOUID, Int32& userID, Int32& userOUID)

   at ManageSoft.Inventory.Importer.DatabaseImport.Begin(Inventory i)

   at ManageSoft.Inventory.Importer.InventoryImporter.Import(String importType, Stream inputStream, Boolean isGzipped, String sourceIdentifier, String targetFilename, MGSLicenseTermCheckResult licenseCheckResult, ImportProcessingStats& stats)
----
Type: 'System.ArgumentException'
Message: 'Item has already been added. Key in dictionary: 'myDomain'  Key being added: 'myDomain''
Source: 'mscorlib'

Cause

In the error above the duplicate key is 'myDomain' however this could be anything. The cause of this error is that "key" is duplicated in the FlatName field of dbo.Domain table e.g. in this scenario there would be 2 records both which have a FlatName of "myDomain", one will likely have a correct DN (qualified name) and one will have a DN that matches the FlatName an example below:
OrganizationID DN FlatName
12345 DC=MyDomain MyDomain
67890

DC=MyDomain,DC=mycompany,DC=com

MyDomain

Resolution

To resolve this issue, simply remove one of the domains. We usually recommend to leave the qualified entry in the database and remove the unqualified entry, an example of a script that could be used is:


DELETE FROM dbo.Domain
WHERE OrganizationID=12345

Additional Information

Make sure to backup the database before you delete any data!

Comments

Powered by Zendesk