The User Profile Service Application enables you to configure a connection to your Active Directory infrastructure and subsequently configure properties that need to be synchronized from AD to your user profile database.
I my case we had a specific need to synchronize the “DepartmentNumber” field in AD to a custom user profile field called “Cost Centre”. However when I tried to select the DepartmentNumber property from the “Add new mapping\Attribute” section (see below) it was not there.
This was quite weird as the property is available via code and AD tools. So after scratching I found that you need to add this field manually to make available. Sharepoint only adds some fields by default (not sure how the decide on which ones). Additionally there is no visual way through CA to add the property, it has to be done via PowerShell. So quick script later and the property was available:
Add-PsSnapin Microsoft.SharePoint.PowerShell
$url = “http://centraladmin:1234” #URL of any site collection that is associated to the user profile service application.
$spsProperty = “CostCentre” #Internal name of the SharePoint user profile property
$fimProperty = “departmentNumber” #Name of the attribute in FIM/LDAP source
$connectionName = “My Active Directory” #Name of the SharePoint synchronization connection$site = Get-SPSite $url
if ($site)
{Write-Host “Successfully obtained site reference!”}
else
{Write-Host “Failed to obtain site reference”}$serviceContext = Get-SPServiceContext($site)
if ($serviceContext)
{Write-Host “Successfully obtained service context!”}
else
{Write-Host “Failed to obtain service context”}
$upManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)if ($upManager)
{Write-Host “Successfully obtained user profile manager!”}
else
{Write-Host “Failed to obtain user profile manager”}
$synchConnection = $upManager.ConnectionManager[$connectionName]if ($synchConnection)
{Write-Host “Successfully obtained synchronization connection!”}
else
{Write-Host “Failed to obtain user synchronization connection!”}Write-Host “Adding the attribute mapping…”
$synchConnection.PropertyMapping.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User, $spsProperty, $fimProperty)
Write-Host “Done!”Remove-PsSnapin Microsoft.SharePoint.PowerShell
Make sure that the account running the script has Admin Access and Permissions on the User Profile Service or it won’t work!