Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Check write permissions for a node without actually writing a value
November 28, 2018
12:24, EET
Avatar
JohannesLipp
Member
Members
Forum Posts: 7
Member Since:
November 12, 2018
sp_UserOfflineSmall Offline

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!

November 28, 2018
14:11, EET
Avatar
Teppo Uimonen
Member
Members
Forum Posts: 21
Member Since:
November 28, 2018
sp_UserOfflineSmall Offline

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:

UaNode node = client.getAddressSpace().getNode(NODEID);
if ((UaVariable)node).getUserAccessLevel().contains(AccessLevel.CurrentWrite) { /* your code here */ }
November 28, 2018
15:48, EET
Avatar
JohannesLipp
Member
Members
Forum Posts: 7
Member Since:
November 12, 2018
sp_UserOfflineSmall Offline

Thank you, this approach worked! Just to be complete, I will post my code snippet below:

UaNode node = uaClient.getAddressSpace().getNode(expandedNodeId);
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.

December 13, 2018
14:23, EET
Avatar
JohannesLipp
Member
Members
Forum Posts: 7
Member Since:
November 12, 2018
sp_UserOfflineSmall Offline

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.

com.prosysopc.ua.StatusException: Bad_UserAccessDenied (0x801F0000) "User does not have permission to perform the requested operation."
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.

December 13, 2018
16:47, EET
Avatar
Teppo Uimonen
Member
Members
Forum Posts: 21
Member Since:
November 28, 2018
sp_UserOfflineSmall Offline

Hello again,

In the above code, you’re using getAccessLevel that gives you Access Levels available for the Node in general. Try getUserAccessLevel, as in my earlier example, and you should get the correct response according to your User Access Level. Hope this works 🙂

December 13, 2018
18:12, EET
Avatar
JohannesLipp
Member
Members
Forum Posts: 7
Member Since:
November 12, 2018
sp_UserOfflineSmall Offline

Oh I missed that detail:

getAccessLevel()

vs.

getUserAccessLevel()

Thank you again!

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
24 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: 737

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6450

Newest Members:

fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1