AnsweredAssumed Answered

Issues with AF SDK in an MVC Application

Question asked by mvisconte on Jul 4, 2017
Latest reply on Jul 6, 2017 by mvisconte

Hello,

In an .NET MVC Application, using Windows Authentication and Impersonation, I am facing an issue with connection to the distant servers.

The code used is as follows (its VB.NET, but I think it is straightforward enough and that C# experts won't mind )

 

Shared Sub FillTagsPI(beginTime As DateTime, endTime As DateTime, TagList As List(Of String))

            Dim oPIServers As New PIServers()

            Dim oAFTimeRange As New AFTimeRange With {.StartTime = New AFTime(beginTime), .EndTime = New AFTime(endTime)}

            Dim oPIServer As PIServer = oPIServers("myserverhostname")

            Dim oPointList As PIPointList = New PIPointList(PIPoint.FindPIPoints(oPIServer, TagList))

               ... ...

 

While this works perfectly fine locally, as soon as I push it to the server, I get an Exception:

Cannot connect to the PI Server. Windows authentication trial failed because insufficient privilege to access the PI Server. Trust authentication trial failed because insufficient privilege to access the PI Server.

With the stack trace

at OSIsoft.AF.PI.PIException.ConvertAndThrowException(PIServer piServer, Exception ex, String message)

at OSIsoft.AF.PI.PIServer.RemoteConnect(AFConnectionPreference preference, NetworkCredential credential, PIAuthenticationMode authenticationMode)

at OSIsoft.AF.PI.PIServer.InternalConnect(Int32 numRetries, IWin32Window owner, AFConnectionPreference preference, NetworkCredential credential, PIAuthenticationMode authenticationMode)

at OSIsoft.AF.PI.PIServer.AutoConnect(Boolean allowDirectConnect, Boolean force)

at OSIsoft.AF.PI.PIPoint.FindPIPoints(PIServer piServer, IEnumerable`1 names, IEnumerable`1 attributeNames)\

at FillTagsPI(DateTime beginTime, DateTime endTime, List`1 TagList)

 

I have checked impersonation, using the Environment.CurrentUser variable just before the call to FindPIPoints, and it is working properly.

Since it works on my development machine, and that I am able to get values using the standard Osisoft tools, such as Process Book, I'd say that the access rights are set properly.

 

I am out of ideas on what could cause these connection errors, and very eager to get any pointers on possible causes.

Please note that due to company policy, remote access to the Web Server is not obvious, but can be arranged if needed.

 

Thanks a lot.

Outcomes