IMD SolutionComputing LibraryShop main store

Troubleshooting

Why a remote AF SDK read fails with a separate Data Archive identity

Edge computing and IIoT Published 7 min read By IMD Solution engineering team

Short answer

The credential passed to PISystem.Connect() authenticates the AF Server only. The PI Data Archive runs a second login against the Windows account your process runs under, or a trust from the client machine, so a remote read of recorded values fails with error -10413, no trust relation, until that account is mapped to a PI identity and the client is trusted. The archive message log in PI SMT names the identity that actually arrived.

On this page
  1. Four checks, four different answers
  2. Two logins on one connection
  3. Read the message log before changing security
  4. Tracing the failed read for local\alapati against AF domain data365
  5. Authorize the identity the archive actually sees
  6. The decision for each case
  7. Questions asked

A remote AF SDK client that loads AF databases and templates but fails the moment it asks for recorded values does not have an AF problem. The credential you pass to PISystem.Connect() is consumed by the AF Server; the PI Data Archive opens its own connection and authenticates the Windows account your process runs under, or a trust from the client machine. When neither is authorized, the archive message log ends in [-10413] No trust relation for this request. The repair is on the Data Archive: map that account to a PI identity with read permission on the points, and allow the trust for the client, both from PI System Management Tools. Stop editing the credentials in Connect(); they are not what the archive rejected.

Four checks, four different answers #

Keep the same target attribute and the same time range through the whole diagnostic sequence. If you change the connection settings and the requested data together, an authentication repair becomes indistinguishable from an unrelated permission difference.

What the client shows What it establishes Next check
Cannot find or connect to the AF Server The fault precedes any archive traffic Known servers entry, port, AF credentials
Connect() succeeds; databases and templates load AF authentication is working The identity the Data Archive sees
Recorded values fail for every attribute The archive login is being refused The Data Archive message log
The archive login succeeds; some attributes return nothing Data authorization, point by point Read permission of the mapped PI identity

If the application cannot reach the AF Server at all, work through why an AF SDK application cannot connect on a client machine first; this article starts where that fault ends, with AF answering and archive data failing. Run every check on the remote client itself, not on the server: the same executable run in the two places uses different Windows identities and can read different client configuration.

Two logins on one connection #

The AF Server supplies the asset model: elements, templates, attribute configuration. An attribute backed by a PI point touches the Data Archive only when the application requests its data, so one process performs two separate authentications:

  • AF login: Connect() with no arguments authenticates with the credentials of the user executing the process; the overload that takes a NetworkCredential supplies an explicit username, password and domain, for the AF connection only.
  • Data Archive login: opened when values are requested, authenticated with the process identity, the Windows account running the program, or with a trust defined for the client machine. The archive keeps its own user security, separate from Windows and from AF, so a credential the AF Server accepted means nothing to it.
// Documented AF SDK types: PISystems, PISystem, NetworkCredential.
PISystems piSystems = new PISystems();
PISystem piSystem = piSystems["MyAFServer"]; // example key from the client's known servers list
piSystem.Connect(); // the AF Server authenticates the user running this process

// The overload that takes a NetworkCredential, with userName, password and domain
// as your own values, changes who the AF Server sees.
// It does not change who the Data Archive sees.

The request that exposes the second login is the data call itself:

// timeRange and pageConfig are your own values; keep both fixed while diagnosing
IEnumerable<AFValues> values =
    attributes.Data.RecordedValues(timeRange, AFBoundaryType.Inside, null, false, pageConfig, 0);

MyAFServer is an example lookup key; use the entry exactly as it stands in the client's known servers list, and confirm that entry with PI System Explorer on the client, the same tool that maintains the connection priority values AF SDK clients use. Those client-side entries are what what a PI System Picker connection needs on the client is about. If PI System Explorer on the client cannot open the AF database, resolve that before touching archive security.

Read the message log before changing security #

  1. Reproduce exactly one failed read from the client and note the time.
  2. Open PI System Management Tools (PI SMT) and search the messages of the Data Archive around that time; the search covers all selected Data Archive servers and collective members.
  3. A refused login leaves up to three lines for that read: Windows authentication failed because the method was not tried; the trust authentication trial failed for insufficient privilege to access the PI Data Archive; then [-10413] No trust relation for this request.
  4. Write down the account named in those lines. That is the identity the archive actually received, and the only one worth authorizing. A client in another domain appears as its own domain and account, never as the credential you handed to AF.

The server-side record is the decisive reading. Guessing from the client side is how people rebuild credentials that were already accepted.

Tracing the failed read for local\alapati against AF domain data365 #

The case: one computer hosts the AF Server and the Data Archive; the C# client runs on a second machine, in another Windows domain, on the same network. The program worked on the server computer and failed only after the move.

Input Value Basis
Process identity on the client local\alapati Client domain and account of the case worked here
Credential given to AF data365\dataadmin plus its password AF server domain and account of the same case
Requested data Recorded values of an attribute backed by a PI point The failing RecordedValues call shown above
Domain relation Client and server in different domains, one network The installation as reported

The rule, in words: the Data Archive never sees the NetworkCredential. A recorded-values read needs, in order, an AF login that succeeds; an archive login that succeeds for the process identity through a PI Mapping or a trust; and read permission on the point for the PI identity that mapping or trust resolves to.

The arithmetic of the failure:

  1. AF login: data365\dataadmin with its password is accepted; databases and templates load. The first check passes.
  2. Archive login, trial one: Windows authentication as local\alapati is not tried, and fails.
  3. Archive login, trial two: the trust lookup for the client machine finds nothing with sufficient privilege, and fails.
  4. Mapping lookup for that account: no PI Mapping exists, so no PI identity resolves, so no point permission is ever evaluated.
  5. Net result: [-10413] No trust relation for this request, and the read returns no data.

The arithmetic of the repair:

  1. Add a PI Mapping on the Data Archive so that account resolves to a PI identity holding read permission on the point.
  2. Allow the trust for the client machine.
  3. Rerun the identical call: the archive login now resolves to the mapped identity, the point permission passes, and values return for the same attribute and time range.

Decision rule: when the log names your own process account above that error, the repair is the mapping and the trust, and no change to Connect() will move that line. When the log instead shows a successful login and the attribute is still empty, the fault is downstream, in the point permission of the mapped identity.

Authorize the identity the archive actually sees #

  1. On the Data Archive, open PI SMT. Under Security, the path Security > Security Settings opens the tool that holds the server's security settings; select the correct Data Archive in the servers list before changing anything.
  2. Create or confirm the PI Mapping for the exact account the log named, resolving to a PI identity.
  3. Allow the trust for the client machine where host-based authentication is wanted.
  4. Grant that PI identity read permission on the points behind the attributes the application reads; the AF database permission the process already holds does not carry over to data.
  5. Rerun the same call, same attribute, same time range, and confirm two things: a non-empty result on the client, and a clean login line in the message log.
  6. For the steady state, run the application, or its Windows service, under a dedicated domain account and map that account: Connect() then needs no credential, and no password sits in a config file.

Give the mapped identity only the reads this application needs: mapping the account to a broadly privileged identity just to silence the message trades a visible error for an invisible exposure.

The decision for each case #

  • The AF Server is unreachable from the client. Fix the known servers entry and client connectivity first; nothing here applies until AF answers.
  • AF answers and every recorded-values read fails, with the failed-trial lines and the no trust relation error in the log. Map the logged account to a PI identity and allow the client's trust; leave the Connect() credentials as they are.
  • The archive login succeeds and some attributes still return nothing. Correct the mapped identity's read permission on those points.
  • The client is a shared or multiuser host. Prefer a dedicated service account with its own mapping over trusting the whole machine.

Questions asked

Why did the same program work when it ran on the server computer?

On the server, the process ran under an account the Data Archive already accepted, through an existing mapping or a trust covering that machine, so the archive login never surfaced. Moving the executable to a client changed the Windows account and the source machine, not the code, and the new combination had neither a mapping nor a trust. Authorize that combination on the Data Archive instead of reinstalling or rewriting the client.

Does allowing a trust for the client machine remove the need for a mapping?

No. Both routes must end at a PI identity with read permission on the points, so a trust alone fixes the login but not data access unless its identity carries the point permission. A trust keyed to the host covers every process on that machine: acceptable on a locked-down gateway box, too broad on a shared workstation, where mapping the domain account the application runs under is the better choice.

The archive login now succeeds, but one attribute still returns no values. What is wrong?

Login and data authorization are separate grants. Once the message log shows a successful login for the mapped identity, an empty attribute points to that point's read permission for the PI identity, or to an attribute that is not backed by a PI point at all. Check the effective identity allowed on the point, then confirm the attribute really references archive data before changing any security.

The application runs on a multiuser web server. Whose identity reaches the Data Archive?

The identity of the worker process, shared by every user behind it, unless the application impersonates the caller for the downstream archive connection. Decide this deliberately: either accept one application identity for all users, or design impersonation and then verify in the archive message log that the impersonated account is the one arriving. Do not widen a shared identity to hide the difference between users.

Keep reading

  • How-to

    Automate daily PI message log collection with pigetmsg

    Query each PI Data Archive remotely with pigetmsg -node and Windows authentication, but run pigetmsg locally on every UniInt interface node, because a PINS node answers a remote query with error -10758 instead of messages. Collect from yesterday's midnight with -st y -et *, append every output with >>, and copy the interface exports into one report.

    Edge computing and IIoT

  • Explainer

    Logging 10 days of history when a small HMI has no historian

    No. A panel without a historian stores only the current value in retentive memory, so 10 days of history is either a ring buffer you program in retentive words (960 words for four variables at hourly sampling) or a job for an edge PC that polls the panel and archives timestamped values, the only route for minute-level data.

    Edge computing and IIoT

  • Explainer

    PI AF SDK: the native path from a C# application to PI

    No driver joins two OPC UA clients, so KEPServerEX needs no new driver for this. Read PI Data Archive and PI Asset Framework from C# through PI AF SDK, which needs the server-side PSA license. Any new values must flow through a real OPC UA server endpoint that a licensed PI OPC UA interface or connector collects from.

    Edge computing and IIoT

Process Historian DCF77 time synchronization fails on the OS server