The script automatically sets a user's SIP address the same as the primary SMTP address.
To use the script with Adaxes, you need to create a business rule triggered after modifying Exchange properties of a user that runs the script using the Run a program or PowerShell script action.
For more information on modifying mailbox addresses using Adaxes ADSI API, see E-Mail Addresses.
PowerShell
# Get Exchange properties
$mailboxParams = $Context.TargetObject.GetMailParameters()
$emailAddresses = $mailboxParams.EmailAddresses
# Get current SIP addresses
$sipAddresses = $emailAddresses.GetAddressesByPrefix("sip")
if ($sipAddresses.Length -eq 0)
{
return # The user doesn't have a SIP address
}
elseif ($sipAddresses.Length -gt 1)
{
$Context.LogMessage("Found more than one SIP address", "Warning")
return
}
# Get primary SMTP address
$smtpAddresses = $emailAddresses.GetAddressesByPrefix("smtp")
foreach ($smtpAddress in $smtpAddresses)
{
if (-not($smtpAddress.IsPrimary))
{
continue
}
$primaryAddress = $smtpAddress.Address
break
}
# Compare Primary SMTP and SIP addresses
$sipAddress = $sipAddresses[0]
if ($sipAddress -ieq $primaryAddress)
{
return # Primary SMTP address was not changed
}
# Change SIP Address
$sipAddress.Address = $primaryAddress
# Save changes
$mailboxParams.EmailAddresses = $emailAddresses
$Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
Is there a version of this script available that can automatically set the SIP address to match the primary SMTP address if the SIP address is missing? Currently, it appears that the script doesn't perform this action if any predefined SIP addresses are already present.
Currently, the script exists if there are no SIP addresses present or there is more than one SIP address. For the first case you need to just create a SIP address matching the primary SMTP one. What about the second case? What should be done then?
When I run it on a user without SIP, there is no SIP after.
When I run it on a user with SIP, it update the SIP to the correct one.
The script don't create the SIP for me, only update if a SIP already is there.
Running Adaxes 2023 V3.15
That is correct for the current script. It is written exactly this way. Do you want the script to just always create a SIP address matching the primary SMTP address no matter of the existing SIP addresses?
Yes please. If a SIP is present update to primary SMTP, if no SIP set it same as primary SMTP.
So there is only one SIP present at the user.
Thank you!
Thank you for the confirmation. Here is the script.
Worked perfectly