12:24, EET
November 12, 2018
Hi there,
I would like to check if I have write permissions to some node on an OPC UA server.
I first found the UserWriteMask which turned out not to be the thing I was searching for.
Then I found the writeValue() methods in the UaClient. The Javadoc lists possible return codes including Bad_WriteNotSupported, Bad_NotWritable, and Bad_UserAccessDenied, which would tell me if a write operation suceeded or not.
However, I do not change values on the OPC UA server in order to check my write permissions.
So my question is:
When I have a UaNoed at the Prosys client, how do I check if I have write permissions without modifying the node?
Thank you!
14:11, EET
November 28, 2018
Hi,
When you want to check the write permissions before writing to a Node, you can check if its UserAccessLevel Attribute includes value CurrentWrite. With a UaNode, this can be done, for example, by first converting it to a UaVariable as shown below:
if ((UaVariable)node).getUserAccessLevel().contains(AccessLevel.CurrentWrite) { /* your code here */ }
15:48, EET
November 12, 2018
Thank you, this approach worked! Just to be complete, I will post my code snippet below:
if (node instanceof UaVariable) {
Set<AccessLevel> accessLevel = ((UaVariable) node).getAccessLevel();
accessLevel.contains(AccessLevel.CurrentRead); // Get read permission
accessLevel.contains(AccessLevel.CurrentWrite); // Get write permission
}
Again, thank you for your fast reply.
14:23, EET
November 12, 2018
Hi Teppo,
I experienced a “permission denied” on read although the read permission discussed above returned true.
Do you have any suggestion how I could verify this in advance, before I get an error during my read operation?
Thank you.
at com.prosysopc.ua.client.UaClient.checkOperationResult(Unknown Source) ~[ProSysSDK-2.2.6-708.jar:2.2.6.708]
at com.prosysopc.ua.client.UaClient.readAttribute(Unknown Source) ~[ProSysSDK-2.2.6-708.jar:2.2.6.708]
What did I do? (1) accessLevel.contains(AccessLevel.CurrentRead) returned true, (2) I called uaClient.readValue(nodeId) and (3) got this error.
Most Users Ever Online: 1919
Currently Online:
21 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 730
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech KubalaModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1