Cutom AD attributes don't show in Attribute drop down list in SharePoint CA for Mange User Property
-
02-10-2020 - |
Вопрос
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:
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?
Решение
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
}