Another Update on this.
A lot of times, organizations want the Manager Name be Available in the Contact Record fetched from Active Directory so that it's easy to fetch all those information in the Asset Record..
The Challenge is that the Manager Name is a Reference Field in Active Directory and if we fetch the Manager Name, the data comes as the DistinguishedName (DN) of the Manager like CN=xxxx, OU=users, OU=Accounts, DC=xyz,DC=com.
The Manager Name is expected simply to be the Name of the Manager which is called the CannonicalName (CN) in the Active Directory.
One Approach to deal with this is to Map this field in the Ca_contact Record with a new attribute let's say manager.
Now everytime you run the LDAP Import Sync, it will fetch the value for this attribute manager which is the DN and can't be changed at the AD level because that 's how AD's architecture is.
Because the CA Mdb doesn't allow to write new triggers at the DB level.
To deal with this, we can write a Stored Procedure in the MDB and schedule it to run every 12 hours let's say, because the Active Directory Sync is run Once a day as a Best Practice.
The Following Stored Procedure query will extract the CN part from the DN of Manager:
Update ca_contact
set manager=Left(manager, CHARINDEX(',',manager)-1)
where manager like 'CN=%'
# This will Set the manager attribute to everything before the first Comma(,) and -1 at the end of the query will trim the comma as well.
#The Result after running this query with manager attribute equal to CN=xxxx, OU=users, OU=Accounts, DC=xyz,DC=com is CN=xxxx
Update ca_contact
set manager= SUBSTRING(manager,4,20)
where manager like 'CN=%'
#This Will take the CN= off the data in the manager attribute which in the Previous query was set to CN=xxxx and the final result in the manager field is xxxx which is the CN of the Manager.
I'm sure there are many other ways to deal with this.
Regards,
Sahil