Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. How To Configure Authorization C++

How to configure authorization C++

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By AlexKuk , 9 August, 2022
Forums
Gurux.DLMS

Hi!

Can you give me some example of authorization.
- How can I add a new user.
- How can I set access to a register, cuz I tried to do like this:
RegPointer->SetAccess(2, DLMS_ACCESS_MODE_AUTHENTICATED_READ);
But it still was available even without authorization.

Profile picture for user Kurumi

Kurumi

3 years 10 months ago

Hi,

Hi,

Are you implementing the meter or reading one?

BR,
Mikko

AlexKuk

3 years 10 months ago

I am implementing one.

I am implementing one.

Profile picture for user Kurumi

Kurumi

3 years 10 months ago

Hi,

Hi,

You don't add users for authorization. The password is validated using ValidateAuthentication method when authentication level is Low. If authentication level is high, you need to create an Association object and set the correct secret for it. The secret is checked automatically.

The attribute access is get using GetAttributeAccess method.

Check this:
https://www.gurux.fi/Gurux.DLMS.Server

BR,
Mikko

AlexKuk

3 years 10 months ago

Okay, I got the theory.

Okay, I got the theory.
But what is the syntaxis in your library?
Cuz I couldn't find any example of it using.
So, I should to call some methods in method 'Init' for server or I should just write the password some where else?

Profile picture for user Kurumi

Kurumi

3 years 10 months ago

Hi,

Hi,

There might be multiple associations and each association might have a different password.
COSEM access rights vary between associations.

Password is check here:

https://github.com/Gurux/GuruxDLMS.c/blob/9a684a6966589b0e59acdcea3d26b…

The access rights are check in svr_getAttributeAccess.

BR,
Mikko

AlexKuk

3 years 10 months ago

Okay, I did this:

Okay, I did this:
CGXByteBuffer buff(20);
buff.AddString("12345");
ValidateAuthentication(DLMS_AUTHENTICATION_LOW, buff);
Inside of int CGXDLMSBase::Init this part of code. But the client still can connect without any auth.
What am I doing wrong?

Profile picture for user Kurumi

Kurumi

3 years 9 months ago

Hi,

Hi,

I'm sorry. You are using ANSI C++ and not ANSI C. This is the correct example:

https://github.com/Gurux/Gurux.DLMS.cpp/blob/ad9528a9678ea80cf12caba2ab…

You don't call the ValidateAuthentication, the framework will call it when needed.

BR,
Mikko

AlexKuk

3 years 9 months ago

Okay, got it thanks.

Okay, got it thanks.

And what should I do to set some password for some auth level?
And also should I do this ->SetAccess() for every register I want to set an access restriction for?
Like this ->SetAccess(2, DLMS_ACCESS_MODE_READ);

Profile picture for user Kurumi

Kurumi

3 years 9 months ago

Hi,

Hi,

Each association has its own password. It's checked by the framework, but you need to set if for the association object. You can set it when association object is create or you can set it like this:

//Find the association object.
CGXDLMSAssociationLogicalName* ln = (CGXDLMSAssociationLogicalName*)GetItems().FindByLN(
DLMS_OBJECT_TYPE_ASSOCIATION_LOGICAL_NAME, "0.0.40.0.0.255");
//Set the secret
CGXByteBuffer secret;
secret.AddString("Gurux");
ln->SetSecret(&secret);

You can check the accessrights using GetAttributeAccess.
Note that accessright might depends from the used association.

https://github.com/Gurux/Gurux.DLMS.cpp/blob/ad9528a9678ea80cf12caba2ab…

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin