Creating Dynamic Exclusions (to avoid duplicates of existing destination addresses)
Created: 2012-04-20 08:09:59Modified: 2017-06-22 11:34:37
Tags: SimpleSync
One of the most common questions is how do I keep duplicate SMTP addresses out of Active Directory or Exchange 5.5
UnitySync by design does not actively read the destination directory to detect duplicates, however another connection can be created that can read all SMTP Addresses from the destination directory and convert it to an exclusion file for your production sync.
In this case well use an Active Directory server as our test destination. Assume we already have a connection in place that syncs to this production AD server as the destination.
Using the Connection > New menu function, create a new connection.
The Source of this connection will be the destination server specified in your original connection, so the source Map Template is ActiveDir and the Source Engine is LDAP. The destination of this connection is a special type... select a destination Map Template of Exclude and a Sync Engine of Text.
On the Source tab, specify the server information which relates to the production destination server from which you want to generate the Exclude list. For Object Types, specify Users and Contacts in order to pull the full compliment of smtp addresses on the source.
The next step is to make sure we dont exclude users that were synced in from your original Production connection. On the Custom tab, Exclude button add a rule to exclude the destination sync container of the original connection.
i.e. dn:ou=Synced Users
Note: If the destination were Exchange 5.5 the following would be used: dn:cn=Synced Users
On the General Tab, ensure both Discovery and Sync are enabled.
Note: By default, all Excludes occur quietly. If you wish your Excludes to produce a notification when your original connection runs, create a custom map file for this Dynamic Exclude connection and prefix the single mapping with a ! character.
i.e. !mail=[allmail]
This marks all Dynamic Excludes as "Special Excludes" and they will be logged at sync time.
The default mapping of mail=[allmail] will create an Exclude file that prevents duplicates when the production sources PRIMARY smtp address is a duplicate. If you also want to prevent duplicates based on production sources SECONDARY smtp addresses, you will need to add a second mapping as follows:
If the source of your production Connection is Ex2000: proxyaddresses :[proxyaddresses]
If the source of your production Connection is Ex55: othermailbox :smtp$[allmail]
The configuration is completed. This connection may be executed using General > Batch Run. And/or it may be run via command line like any other connection.
cd \UnitySync\Programs
shell.exe "AD-Exclude"
Execution of this connection will generate a file called \UnitySync\connections\YourConnectionName\export.txt.
This file is a valid UnitySync exclusion file. You can now take this file and copy it to your production sync as: \UnitySync\Connections\YourProductionConnectionName\exclude.txt.
Important Note: If you already have an exclude.txt in your production connection you will need to merge this file with your existing exclusions.
Once you have gotten exclude.txt into place just run the production connection normally and UnitySync will automatically clean up the duplicates being synced into your destination directory.
Whether or not you will have to run this Dynamic Exclude connection as part of your automated solution depends on whether or not duplicate users may be added manually on the destination. Generation of a new Dynamic Exclude file prior to every production sync will ensure you always have an up to date list of excludes.