DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Optimize TDM Server DataFinder Properties from DIAdem

Hello Everyone,

 

I recently set up a Systemlink (and TDM) Server.

 

Now I want to optimize the properties of a DataFinder I created on the Server with a Script. I obviously could do that manually in the web application but that takes a lot of time.


So I wrote a script for that task but when using the command

Navigator.Display.CurrDataFinder.GetDataFinder.GetSettings.OptimizeCustomProperty(eSearchChannel,"Example_Property",DataTypeString)

i get the error "Access denied."


So basically I'm not allowed to customize the DataFinder which actually makes sense because everyone could just customize it.

 

Does someone know where or how I have to run the script to have access to the DataFinder on the Server?

 

I did not run the script on the server machine but I thought that it probably doesn't matter. I have admin rights for the server though.

 

 

Thanks for you answers!:)

 

 

 

benebelt1

0 Kudos
Message 1 of 5
(2,108 Views)

Hi benebelt,

 

The Navigator object's methods now only work for the "My DataFinder" that ships with DIAdem.  Since the TDM Server (now SystemLink TDM), the only way to programmatically change the DataFinder's settings is to issue web service commands, which DIAdem can do with native VBScript or Python commands.  There are no dedicated commands in DIAdem to do this.  Here's an excerpt from the Swagger documentation of the web service API to configure the DataFinder:

 

DataFinder Web API.png

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 2 of 5
(2,060 Views)

Hi Brad Turpin,

 

thank you for your answer! That really helped me.

 

One more question about that...

I created a MSXML2.xmlHTTP object in DIAdem in order to access the web server and optimize the custom properties.
When I ping it per code in DIAdem it gives me the expected response and editing the optimized property in swagger works too.

 

When I use the object in DIAdem and run

 

dim http
set http = CreateObject ("MSXML2.xmlHTTP")

call http.open("GET", "http://servername/TDMServer_dfse/datafinders", False)
http.send

I get an "Access denied" error. So the server probably won't allow me to access the settings of the server.
As I researched I found the Auth Service on Swagger.

I would be very happy if you could explain me how to authenticate myself and gain access to the settings because I didn't find a solution yet.

 

Thank you!:)

 

benebelt1

0 Kudos
Message 3 of 5
(2,050 Views)

Hi benenelt,

 

What version of SystemLink TDM are you using?  Last summer when SystemLink 2020 R2 released, there was an entirely new security feature introduced based on Workspaces and Roles assigned to specific Users.  The answer for authentication depends strongly on whether you're using a version before or after this feature introduction.

 

For the "after" case, you need to add the Windows User account that is running DIAdem to the Security page and assign it to the same Workspace that the DataFinder is using with a sufficient Role to have permission to change DataFinder settings.  I usually answer this question from customers who want to query the DataFinder from DIAdem, and in the case the role "Data Maintainer" is sufficient.  I'm actually not sure if that will work for changing DataFinder settings.

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 4 of 5
(2,043 Views)

Hi Brad Turpin,

I'm using the newest SystemLink version.
Assigning my user as a Data Maintainer also did not solve the issue.

Thank you for your answer though!


After some more research I found this post:

HTTP request not authorized if not logged on server - NI Community

 

This actually solved my problem.


To sum it up for other people having the same problem:

 

1: Create a Key with Swagger and use the workspace id and a policy id. You can get those on the following way:
1a: workspace id: server->Swagger->User Service->workspaces-> Try it Out-> Execute-> Copy the id

1b: policy id: server->Swagger->Auth Service->policies-> Try it Out -> Execute -> Copy the id

 

2: Then paste the ID's into the suitable placeholder on server -> swagger -> auth service -> Create Key and execute it

 

3: Read out the token next to "secret" which you will need for the "x-ni-api-key" Request Header.

4: With this you are now able to access the server per http and in my case edit the custom properties by using the following code in DIAdem:

 

dim http
set http = CreateObject ("MSXML2.xmlHTTP")

call http.open("PUT", "http://SERVERURL/TDMServer_dfse/datafinders/DatafinderID/customproperties/file?prevent_commit=false", False)
call http.SetRequestHeader("x-ni-api-key", "TOKEN")

'Read the documentation about the body/parameter you need for .send() in swagger.
http.send("{ ""autoexclude"": { ""enabled"": false }, ""items"": [ { ""name"": ""PropertyName"", ""datatype"": ""eDataTypeString"" } ]}"

 

 

Here are links to documention about using the MSXML2.xmlHTTP/XMLHTTPRequest object: XMLHttpRequest Standard (whatwg.org) or Using XMLHttpRequest - Web APIs | MDN (mozilla.org)

 

Hope it helps!

benebelt1

0 Kudos
Message 5 of 5
(2,031 Views)