We have an OPC XML DA server that requires authorization for writing values. Obviously, when I'm trying to write values without specifying username and password I'm getting error saying.
OPC NET API failure result "E_ACCESS_DENIED".
Looking for a solution I've found that I can pass NetworkSecurity object as a parameter of ServerDescriptor constructor, so I changed
new ServerDescriptor("http://IP:port/DA") to new ServerDescriptor("http://IP:port/DA", new NetworkSecurity(user, password)). But, unfortunately it doesn't helped me.
Then I've compared using Wireshark requests sent from dOPC Explorer client and from my program and found that they are differ by Authorization request header. Requests sent from dOPC Explorer contains this header with specified username and password needed for Basic authorization while requests from my app doesn't contain such header at all.
Then I realized that NetworkSecurity might have nothing about HTTP authorization so I simply tried to specify user and password in URL like this:
And now I instead of access denied error I have another one saying
The remote name could not be resolved: 'username'
Here is the code:
ServerDescriptor server = new ServerDescriptor("http://username:password@IP:port/DA");
DAItemDescriptor item = new DAItemDescriptor("item")
OpcClient.WriteItemValue(server, item, "test");
catch (OpcException ex)
Does basic HTTP authorization supported by the library? If yes - could you please correct me what I'm doing wrong.
Thanks in advance!