I'm seeing something odd with AFTable.LinkExternal. When I run it in VS debug mode, it works fine. When I deploy the web service to IIS (same server) it fails on that line of code.
Has anyone seen this type of behaviour before?
Great! The next step is to change the identity of the application pool used by your web site to <domain>\akelley for testing purposes. Later you can change to a more suitable one.
Here is some useful information to make this change.
Specify an Identity for an Application Pool (IIS 7)
Hi, can you share the full method or context? Can you catch and print out the error? Is the IIS app pool running as the same as the dev user account or different? Perhaps the IIS account cannot write to AF.
Sorry, here's the error (but it's pretty generic):
LinkExternal error: System.NullReferenceException: Object reference not set to an instance of an object. at OSIsoft.AF.Asset.AFTable.LinkExternal(AFTableConnection connection, String command, IDictionary`2 parameters)
The line of code is: CurTable.LinkExternal(extConn, CurTable.ExternalCommand, myParameters);
extConn is an existing connection after finding the table (CurTable).
The app pool in IIS is set to default, integrated, running under my domain account (same account used while running in debug mode).
Is there something i need to set in IIS to explicitly give the web service higher privs? Not too familiar with IIS outside of a standard 'add application'.
I suspect you are correct in that the issue might be related to privs on the account.
Are you trying to get external table from where exactly? Is it a database such as SQL Server or Oracle? If it is the first option, can you open SQL Management Studio and check the security logs to make sure the credentials provided were rejected? If it is the second option, I am sure you can do something similar. Another thing you can do if nothing works, it to install VS Remote Debugger on the IIS machine. Then you will be able to attach your VS project to the remote debugger and step in through your code. It might be easier to find the root of the problem with this approach.
If you provide your source code and more details about your issue, we can provide more useful information to help you.
Thanks for your reply. What I was trying to do was use an existing Oracle table connection (already stored in PSE).
I've narrowed down the problem with your help. When i run it in debug mode (same server as IIS), the AFTableConnection.Security has "ReadWrite, Delete, Admin".
When i hit the IIS deployed version which is pointed to the exact same code, the AFTableConnection.Security has only "Read".
So you are correct in that the account cannot write to AF. Assuming I can change that I think that will eventually work.
This brings me to a related question: If I set up a table query with parameters in PSE and just want use the GetTableWithParameters method, would I still have to use LinkExternal and need full privileges as well?
I'm referring to the examples in the documentation here: AFTable.LinkExternal Method (AFTableConnection, String, IDictionary(String, Object))
However, the example is slightly different in that it creates the query within the code. When I use LinkExternal, it does a checkout on that table connection.
It seems like that shouldn't be necessary to merely execute the query with a parameter. Am I understanding that correctly??
Could you please compare the properties CurrentUserIdentityString (of the PI System object) from the dev machine and IIS machine?
I am researching about your other question!
In debug, it is my domain acct: <domain>\akelley but in IIS: <domain>\EDW0032$
This is in our dev environment and EDW0032 is the server where both are running.
The answer is it depends. We are talking about two security layers:
1) Privileges to change the table settings stored on the PI AF Server.
2) Privileges (read only) to access the external data from your client.
If you have read access to the PI AF Server tables and to the external data source. The method GetTableWithParameters should work because you are not changing anything on the server-side, just running a SQL query.
It is important for you to understand that the client retrieves the connection information from AF Server and then it connects directly to the external data source. This means that the user account which is running your application should be the same of the user accessing the external data source, as long as you are using Windows Integrated Security.
I am not understanding why you need to run AFTable.LinkExternal several times or even change the query. The idea of the tables is to store static queries and connection information. You just change the parameters for each execution.
If you need to run different queries every time, you might want to access the table directly using .NET (and not through PI AF SDK).
Hope it helps!
Thank you. Very helful indeed!
Thank you! Appreciate your patience through all of my questions!
Retrieving data ...