Click or drag to resize
OSIsoft, LLC

PIServerConnectWithPrompt Method

Open a connection to the PI Data Archive prompting for credentials to allow sending and retrieving data.

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version:
public void ConnectWithPrompt(
	IWin32Window owner


Type: System.Windows.FormsIWin32Window
The handle to the window that owns the credential prompt dialog. If , then the owner will be the desktop.
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.

The choice of PIAuthenticationMode in the prompt dialog is only displayed if the AllowExplicit option is set in the AuthenticationOptions setting. When this option is not set, then only WindowsAuthentication is allowed.

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.

Note Note
When using this method to connect to a PIServer with an explicit login, the AuthenticationOptions order will be ignored. Even if Windows is not listed, the WindowsAuthentication will be attempted if the user selects it. The PIUserAuthentication mode is only allowed when the AllowExplicit option is set in the AuthenticationOptions setting.
// Get the PIServers collection for the current user and default PIServer.
PIServer myPIServer = new PIServers().DefaultPIServer;

// Simple connect.

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

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


Supported in: 2.10.5, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6, 2.5
See Also
Enabling Operational Intelligence