<div dir="ltr"><div>I'm trying to get state of a VPN connection via DBus in Python. </div><div>Here is my code: </div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"> name="testVPN"<br>
proxy = dbus.SystemBus().get_object('org.freedesktop.NetworkManagerUserSettings', '/org/freedesktop/NetworkManagerSettings')<br> iface = dbus.Interface(proxy, 'org.freedesktop.NetworkManagerSettings')<br>
connections = iface.ListConnections()<br> for connection in connections:<br> proxy = dbus.SystemBus().get_object('org.freedesktop.NetworkManagerUserSettings', connection)<br> iface = dbus.Interface(proxy, 'org.freedesktop.NetworkManagerSettings.Connection')<br>
con_settings = iface.GetSettings()['connection']<br> if con_settings['type'] == 'vpn' and con_settings['id'] == name:<div> state=dbus.Interface(proxy, 'org.freedesktop.DBus.Properties').Get('org.freedesktop.NetworkManager.VPN.Connection', 'VpnState')</div>
</blockquote><div> </div><div><br></div><div>This finds VPN connection correctly but in the last line (when trying to get `VpnState` property) it raises this Exception: </div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div> dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied:
Rejected send message, 1 matched rules; type="method_call",
sender=":1.169" (uid=0 pid=20580 comm="python)
interface="org.freedesktop.DBus.Properties" member="Get" error name="(unset)" requested_reply=0 destination=":1.36" (uid=1000 pid=3457 comm="nm-applet))</div>
</blockquote><div><br></div><div>What is the problem? </div>Thanks<br>
</div>