AnsweredAssumed Answered

Credentials used when accessing AFAttribute.PIPoint?

Question asked by Brad_Lotsberg on Feb 24, 2020
Latest reply on Feb 26, 2020 by Brad_Lotsberg

I have a C#, AFSDK based application that makes a connection to an Asset Framework server using explicit credentials (using the PISystem.Connect(NetworkCredential) function).  If I follow the object chain from any AFElement or AFAttribute back to the PISystem and check the CurrentUserName property, it does indeed reflect the credentials used to connect.

 

However ... if I access a PIPoint object linked to an AFAttribute (to get PIPoint metadata like description etc), the AFSDK seems to be using the currently logged in user to make a connection to the PI data archive server rather than the explicitly provided credentials used for the AF connection.  ie. AFAttribute.PIPoint.Server.CurrentUserName shows the credentials that the application is running under, NOT the credentials used to explicitly connect to the AF server initially.

 

I noticed this behavior when converting my app to run as a window service (just running under the default system user) and saw in my logs that accessing PI AF related objects seemed OK (explicit creds used for AF connection ...) but accessing PIPoint objects linked from AFAttributes was generating permission related errors (ignoring explicit creds and using "current user" ...).  Digging into it with a debugger revealed the credential difference described above.

 

I can understand the AFSDK making a separate connection under the hood to talk to the data archive server, but it's a little odd to me that when crossing from the AF domain to the data archive domain by just following object links it would not use the same credentials used for the initial connection to the AF server but rather default to the current login or credentials under which the app is running.

 

So the question is, is there any way to force the AFSDK to use the same credentials used for the initial AF connection when it needs to connect to the data archive to accommodate code like "AFAttribute.PIPoint...."?

 

I tried making a connection to the data archive with the explicit credentials (which works fine in its own right) but just making that connection in the same app didn't make any difference and I haven't found a way to tell the AFSDK to use the PIServer object obtained that way or to use the same credentials for all connections.

 

Any ideas or even a confirmation that this is just how it works are appreciated.

Outcomes