AnsweredAssumed Answered

Double PI server authentication

Question asked by houskat on Aug 19, 2020
Latest reply on Sep 11, 2020 by vwolf


I have problem with 2 PI servers using with 1 AF in .net code.

I have an element using 2 attributes, 1 attribute refers to PI server 1, the  second to PI server 2.

On both 2 PI servers, there exist the same user name with the same password.

But still, this code connects to only first PI server and refuses to use the same credentials for second PI server.

So my question is, how to proper handle credentials of PI server in .net code using AF SDK.


Well if I am using this:


var srv = PISystem.CreatePISystem("AF server");

if (!srv.ConnectionInfo.IsConnected)
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("UserName", "Password");
srv.Connect(cred, AFConnectionPreference.Any);


and in code I use this init:

foreach (AFAttribute afatt in AFAtts)
var pipoint = afatt.PIPoint;
catch (OSIsoft.AF.PI.PIAuthenticationException e)

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("UserName", "Password");
e.Server.Connect(cred, OSIsoft.AF.PI.PIAuthenticationMode.WindowsAuthentication);


BUT, when this affat is a formula using attributes from PIserver1 and PIserver2, i am not getting this exception. What I get is an empty attribute, not giving any data, nor exception.


What would i like to have is one of this:

  • an event/exception telling me, there is a need to auth
  • a list of PI servers attached to current AF server, so I can authenticate to them
  • setting a default credential - AF SDK uses integrated security as default, but that is not usable, because my code runs under a local service user (or it might run under linux wine/mono)
  • or something which allows me to authenticate to needed PI servers


I tried to make an work&round using PI trust for a machine where this service is running, but it doesnt work (it again works under a normal user, but not under a local system user as a service).