Post-Auth Email Script - get the user's platform

Business solution to host your own OpenVPN server with web management interface and bundled clients.
Post Reply
Epigraphe
OpenVpn Newbie
Posts: 4
Joined: Fri May 05, 2023 5:21 am

Post-Auth Email Script - get the user's platform

Post by Epigraphe » Thu Jun 01, 2023 2:01 pm

Good day.
I update the script for sending a message to the mail when a user connects.
I took the script from viewtopic.php?t=15927 as a basis, but redid it for python 3.
Everything is working as expected, but there was one issue: I can't get the user's platform.
What does the request look like?
I tried to do this

Code: Select all

 if attributes.get('auth_parms'):
            useros = attributes('IV_PLAT')
        else:
            useros = 'Impossible to Determine'
and that

Code: Select all

 if attributes.get('IV_PLAT'):
            useros = attributes('IV_PLAT')
        else:
            useros = 'Impossible to Determine'
and that

Code: Select all

 if attributes.client_info get('auth_parms'):
            useros = attributes.client_info.get('IV_PLAT')
        else:
            useros = 'Impossible to Determine'
with combinations, but all without success.
Thank you.

tieumyxinhdep
OpenVpn Newbie
Posts: 2
Joined: Fri Jun 02, 2023 7:20 am

Re: Post-Auth Email Script - get the user's platform

Post by tieumyxinhdep » Fri Jun 02, 2023 7:27 am

To retrieve the user's platform in your post-auth email script, you can try accessing the appropriate attribute based on the structure of your attributes object. Here's an example that demonstrates how to obtain the user's platform:

python
if 'auth_parms' in attributes:
useros = attributes['auth_parms'].get('IV_PLAT')
else:
useros = 'Impossible to Determine'


In this example, we first check if the 'auth_parms' attribute exists in the attributes object. If it does, we access the 'IV_PLAT' attribute within 'auth_parms' to retrieve the user's platform. Otherwise, we set the platform as 'Impossible to Determine'.

Make sure that the attribute names and object structure match your specific implementation. If the above code doesn't work, it's possible that the attribute containing the user's platform has a different name or is nested differently in the attributes object. In that case, you may need to inspect the structure of the attributes object to identify the correct attribute path for retrieving the user's platform information.

If you provide more details about the structure of the attributes object or the available attributes, I can assist you further in accessing the user's platform correctly.

Epigraphe
OpenVpn Newbie
Posts: 4
Joined: Fri May 05, 2023 5:21 am

Re: Post-Auth Email Script - get the user's platform

Post by Epigraphe » Fri Jun 02, 2023 10:33 am

Thank you for the example and explanation.
I tried - everything works as it should.
Thank you for explaining exactly how to make a request.
Now I can add the rest of the additional information to the letter.

Post Reply