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

Methods

  • Method

  • Description

  • SendSms()

  • Sends an SMS message with the specified text to the recipient represented by this directory object.

  • SendSmsEx()

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

  • EnsureMobileNumberSpecified()

  • Verifies whether a mobile phone number is specified for the directory object.

  • IsSmsSettingsConfigured()

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

  • GetMessageMaxLength()

  • Returns the maximum number of characters in SMS messages.

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 the recipient represented by this directory object. The mobile phone number is obtained from the property of the directory object that is specified in the MobileNumberPropertyName property.

void SendSms(string smsText, bool async)

Parameters

  • smsText - Specifies the text of the SMS message to send. You can use value references (e.g. %name%, %unicodePwd%) in the text. Value references will be replaced with corresponding property values of the directory object that represents the recipient.
  • async - Specifies whether the SMS message will be sent 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 user
$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Send SMS message
$sendAsynchronously = $false
$user.SendSms($smsText, $sendAsynchronously)
C#
using System;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.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 user
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        IAdmSmsOps user = (IAdmSmsOps)service.OpenObject(userPath, null, null, 0);

        // Send SMS 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 of the recipients. You can use value references (e.g. %mobile%) in the value for this parameter. Value references will be replaced with corresponding property values of the directory object that implements this interface.
  • smsText - Specifies the text of the SMS message to send. You can use value references (e.g. %name%, %unicodePwd%) in the text. Value references will be replaced with corresponding property values of the directory object that implements this interface.
  • async - Specifies whether the SMS message will be sent 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 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 SMS message
$sendAsynchronously = $false
$user.SendSmsEx($otherMobile, $smsText, $sendAsynchronously)
C#
using System;
using System.Linq;
using Softerra.Adaxes.Interop.Adsi;
using Softerra.Adaxes.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 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 SMS message
        IAdmSmsOps user2 = (IAdmSmsOps)user;
        const bool sendAsynchronously = false;
        user2.SendSmsEx(otherMobile2, smsText, sendAsynchronously);
    }
}

EnsureMobileNumberSpecified()

Verifies whether a mobile phone number is specified for the directory object.

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()

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