The endpoint URL and selected node are available after the browse dialog closes, but reading the endpoint-level username and password does not return the OPC UA login. The selected credentials are stored under the endpoint descriptor's user-identity object.
Credential Placement Mechanism
The term endpoint descriptor here means the object describing the selected OPC UA endpoint, including its URL and associated user identity. The term user identity means the credentials selected for the OPC UA session. These are separate concerns: the endpoint identifies where and how to connect, while the user identity identifies the account presented when creating the session.
UAEndpointDescriptor.UserName and UAEndpointDescriptor.Password are not the credential path to use for OPC UA. The OPC UA username-token values are nested under UserIdentity.UserNameTokenInfo:
EndpointDescriptor.UserIdentity.UserNameTokenInfo.UserName
EndpointDescriptor.UserIdentity.UserNameTokenInfo.Password
This distinction explains why EndpointDescriptor.UrlString can return a valid endpoint while the endpoint-level credential properties do not return the login. A valid endpoint selection proves that the browser produced an endpoint descriptor; it does not prove that credentials reside in the descriptor's legacy top-level fields.
Selection-Result Validity
Check 1: expect the selected descriptor at SelectionDescriptors[i] to return both the chosen endpoint URL and selected node identifier. This verifies the index, result collection, and accepted browser selection before credential handling is examined.
| Reading | Meaning | Next action |
|---|---|---|
EndpointDescriptor.UrlString returns the chosen URL |
The selected item has an endpoint descriptor. | Read NodeDescriptor.NodeId.expandedText. |
NodeDescriptor.NodeId.expandedText returns the chosen node |
The application is reading the intended selection record. | Continue to Check 2. |
| Either value belongs to another selection |
i refers to the wrong record. |
Correct the iteration or selection index, then repeat Check 1. |
| No usable selection exists | The dialog did not produce an accepted selection to inspect. | Handle cancellation or an empty result before reading credentials. |
Do not diagnose credential storage while the application is reading the wrong descriptor. The endpoint URL and expanded node text form a practical pair for confirming that the selected record is the one the customer accepted.
Endpoint-Property Branch
Check 2: expect EndpointDescriptor.UserName and EndpointDescriptor.Password to be the wrong branch for an OPC UA username token. Documentation describes these properties as normally unused with OPC UA.
If the application currently reads these two properties, redirect it to the nested user-identity path. Do not add fallback logic that silently treats endpoint-level values as OPC UA credentials. Such logic hides the object-model distinction and can associate an identity with the wrong source.
If a top-level value happens to be populated, that does not change the correct OPC UA access path. Continue to Check 3 and compare the nested values with what was entered in the browser.
User-Identity Branch
Check 3: expect EndpointDescriptor.UserIdentity.UserNameTokenInfo.UserName to match the username selected or entered for the OPC UA connection. Expect EndpointDescriptor.UserIdentity.UserNameTokenInfo.Password to represent the corresponding password supplied through the dialog.
| Nested reading | Interpretation | Decision |
|---|---|---|
| Username and password match the dialog input | The username-token identity was retained in the selected endpoint descriptor. | Proceed to the retrieval procedure. |
| Username is empty and no username login was selected | The selection did not use a username-token identity. | Do not treat the empty value as a descriptor failure. |
| A username login was entered, but the nested username does not match | The application may be reading a different selection or a different dialog result. | Repeat Check 1 and inspect the accepted result immediately after closure. |
| Nested properties cannot be reached | The selected result does not expose the expected username-token object at that point in the application flow. | Inspect the identity selected in the dialog and the lifetime of the returned descriptor. |
The identity type is a necessary branch condition. A connection using a non-username identity has no username-token credentials to retrieve. Test the identity selected by the customer instead of interpreting every empty username as an API defect.
Credential Retrieval Procedure
- Wait for the customer to accept and close
UABrowseDialog. Treat cancellation as a separate result. - Iterate the accepted entries in
BrowseDialog.InputsOutputs.SelectionDescriptorsusing the sameithat returns the expected endpoint and node. - Copy the endpoint URL and expanded node identifier from their existing paths.
- Copy the username and password from
UserIdentity.UserNameTokenInfo, not from the top level ofEndpointDescriptor. - Use the copied values for the intended connection flow while the selected descriptor is still valid. If the application must retain them, place them in application-owned storage with access limited to the connection component.
Endpoint := BrowseDialog.InputsOutputs.SelectionDescriptors[i]
.EndpointDescriptor.UrlString;
Tag := BrowseDialog.InputsOutputs.SelectionDescriptors[i]
.NodeDescriptor.NodeId.expandedText;
UserName := BrowseDialog.InputsOutputs.SelectionDescriptors[i]
.EndpointDescriptor.UserIdentity.UserNameTokenInfo.UserName;
Password := BrowseDialog.InputsOutputs.SelectionDescriptors[i]
.EndpointDescriptor.UserIdentity.UserNameTokenInfo.Password;
Treat the password as a secret even if the property is easy to read. Do not write it to logs, exception messages, telemetry, or diagnostic displays. Keep credential lifetime no longer than the session-creation workflow requires.
Resolution Verification
-
Check 4: expect
Endpointto equal the endpoint chosen in the browser. A mismatch returns the investigation to Check 1. -
Check 5: expect
Tagto equal the expanded text of the selected node identifier. This confirms that the endpoint, node, and identity are being taken from the sameSelectionDescriptors[i]entry. -
Check 6: expect
UserNameto equal the username entered for the selected username-token identity. -
Check 7: expect
Passwordto correspond to the password entered in that same accepted dialog result, including an intentionally blank value if the server account permits one. - Check 8: create the OPC UA session with the selected endpoint and retrieved user identity. Expect the server to accept the identity and grant access appropriate to that account; successful local property reads alone do not verify authentication.
FAQ
Can I retrieve OPC UA credentials after UABrowseDialog closes?
Yes. Read the accepted entry in SelectionDescriptors[i] and use EndpointDescriptor.UserIdentity.UserNameTokenInfo.UserName and .Password while that result remains available.
Can I use EndpointDescriptor.UserName for OPC UA?
Do not use it as the OPC UA username-token path. Read the username from EndpointDescriptor.UserIdentity.UserNameTokenInfo.UserName.
Does a retrieved username prove OPC UA authentication works?
No. It proves that the selected descriptor exposes the username-token value. The final verification step is to create the session and expect the server to accept the identity and return the account's intended access.