Specify property for object display names

When you make a request to get a directory object, the object in the response body will always contain the displayName attribute:

{
    ...
    "guid": "7a4267ce-d354-44e7-8bd6-c681f1284a41",
    "dn": "CN=John Smith,CN=Users,DC=example,DC=com",
    "displayName": "John Smith",
    "objectType": "user",
    "objectTypeCode": 2,
    "domainName": "example.com",
    ...
}

By default, the value of the attribute is obtained from the object's relative distinguished name (RDN). In the example above:

  • Distinguished name (DN) is CN=John Smith,CN=Users,DC=example,DC=com
  • Relative distinguished name is CN=John Smith
  • Display name is John Smith

You can configure REST API to obtain object display names from a specific object property, for example, displayName or sAMAccountName.

Note

Out of the box, only Adaxes service administrators have the rights to configure REST API. Other users can be granted such rights using a security role with the Write all properties permission assigned over Configuration objects.

Change settings

To specify the properties to get display names from, execute the following script and restart IIS on the computer where REST API component is installed.

In the script:

  • $serviceHost – the host name of the computer where the Adaxes service is installed.
  • $propertyNames – an array of LDAP property names that will be used to obtain object display names. To reset settings to default, specify $NULL.

Tip

If you include multiple properties in the $propertyNames array, they will be used in the order of priority i.e. if the first property is not specified for an object, its display name is obtained from the second property, and so on. If neither is specified, display name will be obtained from the RDN.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost" 
$propertyNames = @(
    "displayName",
    "sAMAccountName",
    "employeeID"
) 

# Connect to the Adaxes service.
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly($serviceHost)

# Prompt for credentials.
$credential = Get-Credential

# Bind to the REST API configuration container.
$containerPath = $admService.Backend.GetConfigurationContainerPath("ClientAppsContainer")
$container = $admService.OpenObject($containerPath, $credential.UserName,`
    $credential.GetNetworkCredential().Password, 0)
$restApi = $container.RestApi

# Set properties for object display names.
$parameters = $restApi.AdvancedParameters
$displayNameProperties = $parameters.GetParameter("Common.DisplayNameProperties")
$displayNameProperties.Values = $propertyNames
$parameters.SetParameter($displayNameProperties)
$restApi.AdvancedParameters = $parameters
$restApi.SetInfo()

Note

After executing the script, restart IIS on the computer where REST API component is installed.

View current settings

Execute the following script. In the script:

  • $serviceHost – the host name of the computer where the Adaxes service is installed.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$serviceHost = "localhost" 

# Connect to the Adaxes service.
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly($serviceHost)

# Prompt for credentials.
$credential = Get-Credential

# Bind to the REST API configuration container.
$containerPath = $admService.Backend.GetConfigurationContainerPath("ClientAppsContainer")
$container = $admService.OpenObject($containerPath, $credential.UserName,`
    $credential.GetNetworkCredential().Password, 0)
$restApi = $container.RestApi

# Properties for display names.
$parameters = $restApi.AdvancedParameters
$displayNameProperties = $parameters.GetParameter("Common.DisplayNameProperties")

if ($NULL -eq $displayNameProperties.Values) 
{
    Write-Host "Display names obtained from: <Default>"
}
else
{
    Write-Host "Display names obtained from: $($displayNameProperties.Values)"
}