IAdmSmsOps

The IAdmSmsOps interface is used to send SMS messages via Adaxes.

All directory objects in Adaxes implement the IAdmSmsOps interface. To use this interface, you need to bind to a directory object you want to send an SMS message to.

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

$smsText = "Hello %name%, your password expires on %adm-PasswordExpires%."

# Connect to the Adaxes service.
$ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$service = $ns.GetServiceDirectly("localhost")

# Bind to a user.
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Send the message.
$sendAsynchronously = $false
$user.SendSms($smsText, $sendAsynchronously)
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string smsText = 
            "Hello %name%, your password expires on %adm-PasswordExpires%.";

        // Connect to the Adaxes service.
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to a user.
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        IAdmSmsOps user = (IAdmSmsOps)service.OpenObject(userPath, null, null, 0);

        // Send the message
        const bool sendAsynchronously = false;
        user.SendSms(smsText, sendAsynchronously);
    }
}

Methods

Properties

  • Property

  • Description

  • MobileNumberPropertyName

  • Gets the name of the property that is used to store mobile phone numbers for directory objects.

  • SmtpRequired

  • Gets a value indicating whether SMTP settings should be configured to send SMS messages.

Details

SendSms()

Sends an SMS message with the specified text to a recipient represented by a directory object. The mobile phone number is obtained from the property of the directory object that is specified in the MobileNumberPropertyName property of this interface.

void SendSms(string smsText, bool async)

Parameters

  • smsText – the message text. You can use value references (e.g. %name%, %unicodePwd%) in the message. They will be replaced with the corresponding property values of the recipient object.
  • async – specifies whether to send the SMS message asynchronously.

Examples

The following code sample sends an SMS message to a user.

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

$smsText = "Hello %name%, your password expires on %adm-PasswordExpires%."

# Connect to the Adaxes service.
$ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$service = $ns.GetServiceDirectly("localhost")

# Bind to a user.
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Send the message.
$sendAsynchronously = $false
$user.SendSms($smsText, $sendAsynchronously)
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string smsText = 
            "Hello %name%, your password expires on %adm-PasswordExpires%.";

        // Connect to the Adaxes service.
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to a user.
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        IAdmSmsOps user = (IAdmSmsOps)service.OpenObject(userPath, null, null, 0);

        // Send the message
        const bool sendAsynchronously = false;
        user.SendSms(smsText, sendAsynchronously);
    }
}

SendSmsEx()

Sends an SMS message with the specified text to the given mobile phone numbers.

void SendSmsEx(string mobileNumbers,
               string smsText,
               bool async)

Parameters

  • mobileNumbers – a semicolon-separated list of mobile phone numbers. You can use value references (e.g. %mobile%) in the parameter value. They will be replaced with the corresponding property values of the directory object that implements this interface.
  • smsText – the message text. You can use value references (e.g. %name%, %unicodePwd%) in the message. They will be replaced with the corresponding property values of the directory object that implements this interface.
  • async – specifies whether to send the SMS message asynchronously.

Examples

The following code sample sends an SMS message to mobile phone numbers stored in the otherMobile property of a user.

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

$smsText = "Hello %name%, your password expires on %adm-PasswordExpires%."

# Connect to the Adaxes service.
$ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$service = $ns.GetServiceDirectly("localhost")

# Bind to a user.
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Get mobile phone numbers stored in the otherMobile property.
$otherMobile = $user.GetEx("otherMobile")
$otherMobile = $otherMobile -Join ";"

# Send the message.
$sendAsynchronously = $false
$user.SendSmsEx($otherMobile, $smsText, $sendAsynchronously)
C#
using System;
using System.Linq;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string smsText = 
            "Hello %name%, your password expires on %adm-PasswordExpires%.";

        // Connect to the Adaxes service.
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to a user.
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        IADs user = (IADs)service.OpenObject(userPath, null, null, 0);

        // Get mobile phone numbers stored in the otherMobile property.
        object[] otherMobile = (object[])user.GetEx("otherMobile");
        string otherMobile2 = string.Join(";", otherMobile.Cast<string>().ToArray());

        // Send the message.
        IAdmSmsOps user2 = (IAdmSmsOps)user;
        const bool sendAsynchronously = false;
        user2.SendSmsEx(otherMobile2, smsText, sendAsynchronously);
    }
}

EnsureMobileNumberSpecified()

Verifies whether a directory object has a mobile phone number specified. If the object property specified in MobileNumberPropertyName is empty, this method will throw an exception.

void EnsureMobileNumberSpecified()

Exceptions

  • COMException
  • Mobile phone number is not specified.

IsSmsSettingsConfigured()

Verifies whether SMS settings are configured to send SMS messages via the Adaxes service.

bool IsSmsSettingsConfigured()

Remarks

This method doesn't check for misconfiguration, i.e. whether messages can actually be sent. It only verifies that the settings are not blank.


GetMessageMaxLength()

Returns the maximum number of characters in SMS messages. Messages that exceed the limit are truncated by Adaxes.

int GetMessageMaxLength()

MobileNumberPropertyName

Gets the name of the property that is used to store mobile phone numbers for directory objects.

  • Type:
  • string
  • Access:
  • Read-only

SmtpRequired

Gets a value indicating whether SMTP settings should be configured to send SMS messages. The property is true if IAdmSendSmsGatewaySettings::GatewayType is set to ADM_SMSGATEWAYTYPE_EMAIL.

  • Type:
  • bool
  • Access:
  • Read-only

Requirements

Minimum required version: 2023

See also