We have several domains in use. A users default email reply to address is based on brand employee is working for.
Default value in the property pattern is %firstname:lower%.%lastname:lower%
Is it possible to add domain based on OU user belongs to?
For UPN there's PS Script:
$propertyName = "company" # TODO: modify me
$upnSuffixMap = @{
"aaa.com" = @("aaa")
"bbb.com" = @("bbb")
"ccc.com" = @("ccc")
"company.local" = @("External")
} # TODO: modify. Example: $upnSuffixMap = @{"<UPN Suffix>" = @("<Property Value 1>", "<Property Value 2>")}
# Get property value
try
{
$value = $Context.TargetObject.Get($propertyName)
}
catch
{
return # Property is empty
}
# Get UPN Suffix
$upnSuffix = $NULL
foreach ($item in $upnSuffixMap.GetEnumerator())
{
if ($item.Value -notcontains $value)
{
continue
}
$upnSuffix = $item.Key
break
}
if ([System.String]::IsNullOrEmpty($upnSuffix))
{
$Context.LogMessage("UPN suffix is not specified for '$value'. Default UPN suffix will be used.", "Warning")
return
}
# Get UPN
$userPrincipalName = "%userPrincipalName%"
if ([System.String]::IsNullOrEmpty($userPrincipalName))
{
$Context.LogMessage("Cannot assign a UPN suffix because the user logon name is empty", "Warning")
return
}
# Build new UPN
$userPrincipalName = $userPrincipalName.SubString(0, $userPrincipalName.IndexOf("@")) + "@$upnSuffix"
# Save changes
$Context.TargetObject.Put("userPrincipalName", $userPrincipalName)
$Context.TargetObject.SetInfo()