Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
MatteoGuadrini committed Aug 4, 2020
2 parents cda19f3 + 740df29 commit b84c7a5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Read these RFCs carefully ([RFC 3580](https://tools.ietf.org/html/rfc3580), [RFC
[RFC 2865](https://tools.ietf.org/html/rfc2865), [RFC 3579](https://tools.ietf.org/html/rfc3579)) and choose a radius server based on your architecture
([freeradius](https://freeradius.org/) or [Microsoft Radius](https://docs.microsoft.com/it-it/windows-server/networking/technologies/nps/nps-top)).

Once the network equipment and radius server have been configured, create ldap groups corresponding to the VLAn that you want to manage.
Once the network equipment and radius server have been configured, create ldap groups corresponding to the VLAN that you want to manage.

e.g .: *VLAN_ID 100 on switch to group LDAP VLAN100.*

Expand All @@ -104,7 +104,7 @@ You can configure _vmam_ before configuring your network architecture.

You can start creating a default file by typing: `vmam config --new`

This will create a standard configuration file under `/etc/vmam/vmam.conf` on Unix and `C:\vmam\vmam.conf` on Windows.
This will create a standard configuration file under `/etc/vmam/vmam.conf`.

Now it will be enough, edit and customize the configuration file following the documentation as guidelines. Once done, type `vmam config --get-cmd`

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from setuptools import setup

VERSION = '1.3.2'
VERSION = '1.3.3'

if not os.path.exists('bin'):
os.makedirs('bin')
Expand Down
2 changes: 1 addition & 1 deletion vmam.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Manpage for vmam.
.\" Contact [email protected] to correct errors or typos.
.TH man 1 "9 May 2020" "1.3.2" "vmam man page"
.TH man 1 "9 May 2020" "1.3.3" "vmam man page"
.SH NAME
vmam \- VLAN Mac\-address Authentication Manager
.SH SYNOPSIS
Expand Down
37 changes: 20 additions & 17 deletions vmam.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def check_module(module):
# endregion

# region Global variable
VERSION = '1.3.2'
VERSION = '1.3.3'
__all__ = ['logwriter', 'debugger', 'confirm', 'read_config', 'get_platform', 'new_config', 'bind_ldap',
'check_connection', 'check_config', 'connect_ldap', 'unbind_ldap', 'query_ldap', 'check_ldap_version',
'new_user', 'set_user', 'delete_user', 'set_user_password', 'add_to_group', 'remove_to_group',
Expand Down Expand Up @@ -936,8 +936,8 @@ def format_mac(mac_address, mac_format='none'):
.. testcode::
>>> mac = format_mac('1A2b3c4D5E6F', 'dot')
>>> print(mac)
>>> m = format_mac('1A2b3c4D5E6F', 'dot')
>>> print(m)
"""
# Set format
form = {
Expand Down Expand Up @@ -1020,8 +1020,8 @@ def get_mac_address(protocol, *exclude):
.. testcode::
>>> cl = connect_client('host1', r'domain\\user', 'password')
>>> mac = get_mac_address(cl)
>>> print(mac)
>>> m = get_mac_address(cl)
>>> print(m)
"""
# Get all mac-address on machine
macs = list(run_command(protocol, 'getmac /fo csv /v'))
Expand Down Expand Up @@ -1054,8 +1054,8 @@ def get_client_user(protocol):
.. testcode::
>>> cl = connect_client('host1', r'domain\\user', 'password')
>>> user = get_client_user(cl)
>>> print(user)
>>> u = get_client_user(cl)
>>> print(u)
"""
# Get the users connected
users = list(run_command(protocol, 'quser'))
Expand Down Expand Up @@ -1629,7 +1629,8 @@ def cli_start(arguments):
','.join(cfg['LDAP']['servers']), cfg['LDAP']['bind_user']))
bind_start = bind_ldap(srv, cfg['LDAP']['bind_user'], cfg['LDAP']['bind_pwd'], tls=cfg['LDAP']['tls'])
# Get computers from domain controllers
debugger(arguments.verbose, wt, 'Convert datetime format to filetime format for computer query')
debugger(arguments.verbose, wt, 'Convert datetime format to filetime format for computer query: {0} ago'.format(
cfg['LDAP']['time_computer_sync']))
td = get_time_sync(cfg['LDAP']['time_computer_sync'])
ft = datetime_to_filetime(td)
# Query LDAP to take all computer accounts based on filetime
Expand All @@ -1644,7 +1645,8 @@ def cli_start(arguments):
debugger(arguments.verbose, wt, 'Try connect to {0} via WINRM'.format(c_attribute['name']))
if check_connection(c_attribute['name'], 5985):
try:
debugger(arguments.verbose, wt, 'Connect to {0} via WINRM'.format(c_attribute['name']))
debugger(arguments.verbose, wt, 'Connected successful to {0} via WINRM'.format(
c_attribute['name']))
client = connect_client(c_attribute['name'], cfg['VMAM']['winrm_user'],
cfg['VMAM']['winrm_pwd'])
# Run the commands
Expand All @@ -1661,14 +1663,14 @@ def cli_start(arguments):
c_attribute['name']))
wt.warning('There are no mac-addresses present on {0} computer'.format(
c_attribute['name']))
continue
# Get the last user of the computer
debugger(arguments.verbose, wt, 'Get users of {0}'.format(c_attribute['name']))
debugger(arguments.verbose, wt, 'Get logged in users of {0}'.format(c_attribute['name']))
users = get_client_user(client)
# Check user list
if not users:
print('WARNING: No user logged in on {0} computer'.format(c_attribute['name']))
wt.warning('No user logged in on {0} computer'.format(c_attribute['name']))
print('WARNING: There are no logged in users on {0} computer'.format(
c_attribute['name']))
wt.warning('There are no logged in users on {0} computer'.format(c_attribute['name']))
continue
# Search user on LDAP server
try:
Expand Down Expand Up @@ -1811,11 +1813,14 @@ def cli_start(arguments):
wt.error(err)
continue
else:
debugger(arguments.verbose, wt, 'Computer {0} unreachable'.format(c_attribute['name']))
debugger(arguments.verbose, wt, 'Computer {0} is unreachable'.format(c_attribute['name']))
if cfg['VMAM'].get('remove_process'):
debugger(arguments.verbose, wt, 'Start disable/delete process')
# Get old mac-address user
debugger(arguments.verbose, wt, 'Convert datetime format to filetime format for mac-address user query')
debugger(arguments.verbose, wt,
'Convert datetime format to filetime format for mac-address user query. mac ttl: {0}'.format(
cfg['LDAP']['mac_user_ttl']
))
# Get value for soft deletion
soft_deletion = cfg['VMAM']['soft_deletion']
td = get_time_sync(cfg['LDAP']['mac_user_ttl'])
Expand All @@ -1836,8 +1841,6 @@ def cli_start(arguments):
str(datetime.date.today()), str(last_access.date()),
mac.get('attributes').get('description')
)
# Set new description

# Disable mac-address
cli_disable_mac(cfg, bind_start, mac.get('attributes').get('samaccountname'), wt, arguments,
description=desc)
Expand Down

0 comments on commit b84c7a5

Please sign in to comment.