Click or drag to resize
OSIsoft, LLC

PIServerConnect Method (NetworkCredential, PIAuthenticationMode)

Open a connection to the PI Data Archive using the specified credentials to allow sending and retrieving data.

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.8.440
Syntax
public void Connect(
	NetworkCredential credential,
	PIAuthenticationMode authenticationMode
)

Parameters

credential
Type: System.NetNetworkCredential
The NetworkCredential to use when connecting to the server.
authenticationMode
Type: OSIsoft.AF.PIPIAuthenticationMode
Specifies the type of authentication to be used when making the connection. The specified credential must match the type of authentication.
Exceptions
ExceptionCondition
PIConnectionExceptionA connection to the PI Data Archive server cannot be made.
PIVersionNotSupportedException This exception will be generated when attempting to connect to a PIServer with using WindowsAuthentication and the server does not support this mode of authentication.
Remarks
If an application accesses a property or invokes a method that requires server access, an implicit connection is performed. When a connection is no longer needed, it can be closed using the Disconnect method.
Examples
// Get the PIServers collection for the current user and default PIServer.
PIServer myPIServer = new PIServers().DefaultPIServer;

// Simple connect.
myPIServer.Connect();
myPIServer.Disconnect();

// Connect and display a credential prompt dialog if current user login fails.
myPIServer.Connect(true, null);
myPIServer.Disconnect();

try
{
    // Connect using a specified credential.
    NetworkCredential credential = new NetworkCredential("guest", String.Empty);
    myPIServer.Connect(credential);
}
catch (Exception ex)
{
    // Expected exception since credential needs a valid user name and password.
    Console.WriteLine(ex.Message);
}
Version Information

AFSDK

Supported in: 2.10.5, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6
See Also