1

There is a Custom AD attribute that is mapped in SharePoint 2010 farm. We created a new SharePoint 2013 farm and when we tried to map the AD attribute from CA we don't see the custom attribute in the drop down list:

enter image description here

I have tried doing full import to no avail, what is also interesting, is going back to SharePoint 2010 farm and trying to create a new property under Manage User Properties in CA I do not see that attribute in the drop down list...I found this Blog: http://sadomovalex.blogspot.ca/2011/02/create-custom-ad-attribute-and-map-it.html but I have not tried it and I don't want to try it for now unless there are no other options.

Any idea or any steps I need to take to troubleshoot the issue?

1 Answer 1

1

Same happened to me. The only way I found how to map them is PowerShell. Worked like a charm.

    Add-PSSnapin Microsoft.sharepoint.powershell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles")

function Get-SPServiceContext([Microsoft.SharePoint.Administration.SPServiceApplication]$profileApp) {
    $profileApp = @(Get-SPServiceApplication | ?  {$_.TypeName -eq "User Profile Service Application"})[0]
    return [Microsoft.SharePoint.SPServiceContext]::GetContext($profileApp.ServiceApplicationProxyGroup,[Microsoft.SharePoint.SPSiteSubscriptionIdentifier]::Default)
}

function Add-CustomProperty($name, $displayName, $showOnEdit, $userEdit, $showOnProfile, $type, $length, $mapTo, $upm) {
    $PropertyName = $name
    $PropertyDisplayName = $displayName 

    if ($upm.GetPropertyByName($name) -eq $null) {

        $coreProperty = $upm.Create($false)
        $coreProperty.Name = $PropertyName
        $coreProperty.DisplayName = $PropertyDisplayName
        $coreProperty.Type = $type
        $coreProperty.Length =  $length
        $coreProperty.IsAlias = $false;
        $coreProperty.IsSearchable = $true;

        $userProfileConfigManager.ProfilePropertyManager.GetCoreProperties().Add($coreProperty)

        $profileTypeProperty = $userProfileTypeProperties.Create($coreProperty)
        $profileTypeProperty.IsVisibleOnEditor = $showOnEdit
        $profileTypeProperty.IsVisibleOnViewer = $showOnProfile
        $userProfileTypeProperties.Add($profileTypeProperty)

        if ($mapTo -ne $null) {
            $attributeName = $mapTo
            $synchConnection = $userProfileConfigManager.ConnectionManager[$connectionName]
            $synchConnection.PropertyMapping.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User,$PropertyName,$attributeName)
        }

        $subTypeProperty = $userProfileProperties.Create($profileTypeProperty)
        $subTypeProperty.IsUserEditable = $userEdit
        $subTypeProperty.DefaultPrivacy = "Public"
        $userProfileProperties.Add($subTypeProperty)
    }
}

function Remove-CustomProperty($name, $upm) {

    $upm.RemovePropertyByName($name)
}

#SharePoint Synchronization connection
$connectionName ="AD_CONNECTION_NAME"

#Get UserProfileManager 
$serviceContext = Get-SPServiceContext      
$userProfileConfigManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)
$userProfilePropertyManager = $userProfileConfigManager.ProfilePropertyManager
$userProfilePropertyCreateManager = $userProfilePropertyManager.GetCoreProperties()
$userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User)
$userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($serviceContext)
$userProfile = $userProfileSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User))
$userProfileProperties = $userProfile.Properties 

if ($userProfilePropertyManager -ne $null -and $userProfilePropertyCreateManager -ne $null) {
    Add-CustomProperty "DepartmentNo" "Department No" $false $false $true "string" "25" "departmentNumber" $userProfilePropertyCreateManager
}
2
  • Property was added but not maped to the attribute ,got this error---> You cannot call a method on a null-valued expression. At line:34 char:13 + $synchConnection.PropertyMapping.AddNewMapping([Microsoft ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
    – Akhilesh
    Apr 10, 2018 at 4:46
  • $synchConnection is null. Your $connectionName is probably incorrect :) Apr 26, 2018 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.