TerminateConnection Method


Terminate a specified session or connection of specified service.

long TerminateConnection(
	[in] BSTR Service, 
	[in] BSTR Identifier
)

Parameters

Service

Service name, it can be smtpd, pop3d, webmail or rocd.

Identifier

Identifier of the connection to be terminated. It can be retrieved by GetConnectionInfo method.

Return Value

Return value is zero if this method succeeds; otherwise return value is non-zero.

Usage Example

Dim server, user, password, requestAddr
server = "localhost"
user = "system"
password = "mypassword"
requestAddr = "192.168.0.1"

Dim oSvr
Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
r = oSvr.Connect( server, user, password, 0, requestAddr )
If r <> 0 Then
  WScript.Echo( "connect server failed!" )
End If

Dim oServices
Set oServices = oSvr.ServiceCollection
'get smtp service active connections
Dim ConnInfos
ConnInfos = oServices.GetConnectionInfo("smtpd")

Dim arConnId
arConnId = Split(ConnInfos, Chr(10)) 'split each connection to an array.

Dim i, nCount, Identifier
nCount = UBound(arConnId)
For i = LBound(arConnId) To nCount
  Identifier = Trim(arConnId(i))
  If Identifier  <> "" Then
    'terminate every smtp service active connection
    oServices.TerminateConnection "smtpd", Identifier 
  End If
Next