AFCollectiveMember.Connect Method (NetworkCredential)
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
Namespace: OSIsoft.AF.Collective
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public void Connect( NetworkCredential credential )
Public Sub Connect ( credential As NetworkCredential ) Dim instance As AFCollectiveMember Dim credential As NetworkCredential instance.Connect(credential)
public: void Connect( NetworkCredential^ credential )
member Connect : credential : NetworkCredential -> unit
Parameters
- credential
- Type: System.NetNetworkCredential
The NetworkCredential to use when connecting to the server.
Events
| Event Type | Reason |
|---|---|
| PISystemConnectChanged | This event will be raised when the connection status for the PISystem changes. |
Exceptions
| Exception | Condition |
|---|---|
| InvalidOperationException | This exception is thrown if connecting to the collective member is disabled because of it Priority setting. |
Remarks
The connection to the specific remote server in the AFCollective is established using the AFCollectiveMember configuration information. When finished with the connection, the PISystem.Disconnect method should be called to free resources used by the connection.
Use the Connect(bool, IWin32Window) method to automatically provide a dialog to prompt for user credentials if the logon fails. Use the Connect(NetworkCredential) method to provide user credentials to be used when connecting to the PISystem.
Examples
// Get the PISystems collection for the current user and default PISystem. PISystem myPISystem = new PISystems().DefaultPISystem; // Set default for all connections to be based upon collective member's priority. AFConnectionInfo.DefaultPreference = AFConnectionPreference.Any; AFCollectiveMember myMember; // Simple connect will use Default Preference. myPISystem.Connect(); myPISystem.Disconnect(); // Check if default PISystem is a Collective. if (myPISystem.Collective != null) { // Connect specifying that Primary is required and display a credential // Connect and display a credential prompt dialog if current user login fails. // Only available in .Net Framework AFSDK // myPISystem.Connect(true, null, AFConnectionPreference.RequirePrimary); // myPISystem.Disconnect(); // Connect specifying that Primary is required and display a credential // Connect and display a credential prompt dialog if current user login fails. // Only available in .Net Framework AFSDK. // Connect to a specific collective member and display a credential // Prompt dialog if current user login fails. // myMember = myPISystem.Collective.Members[0]; // myMember.Connect(true, null); // myPISystem.Disconnect(); try { // Connect to a specific collective member using a specified credential. myMember = myPISystem.Collective.Members[0]; NetworkCredential credential = new NetworkCredential("guest", String.Empty); myMember.Connect(credential); } catch (Exception ex) { // Expected exception since credential needs a valid user name and password. Console.WriteLine(ex.Message); } }
' Get the PISystems collection for the current user and default PISystem. Dim myPISystem As PISystem = New PISystems().DefaultPISystem ' Set default for all connections to be based upon collective member's priority. AFConnectionInfo.DefaultPreference = AFConnectionPreference.Any Dim myMember As AFCollectiveMember ' Simple connect will use Default Preference. myPISystem.Connect() myPISystem.Disconnect() ' Check if default PISystem is a Collective. If (myPISystem.Collective IsNot Nothing) Then ' Connect specifying that Primary is required and display a credential ' Prompt dialog if current user login fails. ' Only available in .Net Framework AFSDK ' myPISystem.Connect(True, Nothing, AFConnectionPreference.RequirePrimary) ' myPISystem.Disconnect() ' Connect to a specific collective member and display a credential ' Prompt dialog if current user login fails. ' Only available in .Net Framework AFSDK ' myMember = myPISystem.Collective.Members(0) ' myMember.Connect(True, Nothing) ' myPISystem.Disconnect() Try ' Connect to a specific collective member using a specified credential. myMember = myPISystem.Collective.Members(0) Dim credential As NetworkCredential = New NetworkCredential("guest", String.Empty) myMember.Connect(credential) Catch ex As Exception ' Expected exception since credential needs a valid user name and password. Console.WriteLine(ex.Message) End Try End If
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.