From 48be235fdef46a9d12967de765a0b28690f86dae Mon Sep 17 00:00:00 2001 From: aitzol Date: Wed, 29 Nov 2023 23:10:24 +0100 Subject: [PATCH] devices, ip attributes --- app.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index 3059435..8ddb61a 100644 --- a/app.py +++ b/app.py @@ -1027,7 +1027,10 @@ def get_user_data(user_dn, conn): data.append(conn.entries[0].uid.values[0]) data.append(conn.entries[0].mail.values[0]) data.append(conn.entries[0].devices.values) - data.append(conn.entries[0].ip.values[0]) + if(conn.entries[0].ip): + data.append(conn.entries[0].ip.values[0]) + else: + data.append(request.environ.get('HTTP_X_REAL_IP', request.remote_addr)) #ts = conn.entries[0].lastLogin.values[0] #ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S%z') #ts = datetime.strftime(t, '%Y-%m-%d %H:%M:%S') @@ -1074,14 +1077,6 @@ def is_trusted_device(conf, user_dn): if not find_device(user_dn, c, d): OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement'] c.modify(user_dn, {'devices': [( MODIFY_ADD, d )] }) - ''' - if find_device(user_dn, c, 'unknown'): - OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement'] - c.modify(user_dn, {'devices': [( MODIFY_REPLACE, d )] }) - else: - OBJECT_CLASS = ['top', 'inetOrgPerson', 'posixAccount', 'accountsManagement'] - c.modify(user_dn, {'devices': [( MODIFY_ADD, d )] }) - ''' c.unbind() return True except Exception as e: