Open_s Method (IServerConnect interface)

              

 

Open_s provides an alternate to the Server.Open method where the connection string argument is an array of bytes rather than a string . 

 

Syntax

object.Open_s  arrConnectString

The RefreshToDepth method syntax has these parts:

Part

Description

object

An object expression that evaluates to a reference to an IServerConnect interface. 

arrConnectString

An array of bytes containing the connection string in Unicode.  The last element should be a 0 to null terminate the SAFEARRAY of BYTE elements.   

 

 

Remarks

 

BSTR variables are system strings and their lifetime is controlled by the Operating System. When a program calls Server.Open and passes a connection string which can include a password (UID=mmm;PWD=nnn), the string can remain in memory after the PI-SDK is done with it until the system string is cleared or reused.  This creates the potential for someone to dump memory and discover the password even though the PI-SDK encrypts the connection string it holds for reconnection.  By passing an array of characters rather than a string to Open_s, this behavior is avoided and the connection string is not found in the memory image of a running program.

 

When calling this routine the programmer is responsible for the clearing variables that they use that hold sensitive data (connection string).  Typically the passed connection string should be cleared immediately after the Open_s call returns.  Be careful to understand the compiler optimizations being used as code which clears a variable and never uses it again could be optimized out of the program leaving the secret text in memory unencrypted. 

 

For complete documentation of the connection string syntax and Open behaviors consult the Server.Open documentation.

 

Enabling Operational Intelligence