Détails du package

smp-add-macaddress-computer-ad

retour Revenir à la liste des packages

smp-add-macaddress-computer-ad

Fichier control :

package           : smp-add-macaddress-computer-ad
version           : 5
architecture      : all
section           : base
priority          : optional
name              : 
categories        : 
maintainer        : Simon Fonteneau
description       : Add macAddress in attribut computer in AD
depends           : 
conflicts         : 
maturity          : UPDATE_PACKAGE_ONLY
locale            : 
target_os         : 
min_os_version    : 
max_os_version    : 
min_wapt_version  : 1.5
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : 
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : effa1d01-c02e-44d2-8849-cd68aa38f25b
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 1e54425be03a2a3ea1a264b40d984c31f17a6a489a3b722acb993cbf6561e903
signature         : zb9bt/FNGy2GBvuuFODoarGbfiOTB3NROV1h3Bepetdl56ovf2txiIjEJwOV8XGwDnz9vefXXZ3v6QBQl3lNbqGe21zi5RFdD85pbKLCY3CXymg/j84yjlICJbsR6/QlQtWoKUmxsMzSaIYxsiOV3/59GcXS+jYfmndWBuHyBjZxIw9KyxozdqkVs1DiPaYywawtGjr/gu5zi2JrKpMTtQEtedN6r17VyDIiX1GqygoYLZx9QcObyr/U5vFtVvG+KJDYbXhCTgVXIRoAT01w6lJjaSNmWAzj00DPDjtRY0zbR2ljhnp0gAAlByj5X0V4Pyu2Yao0tK8ScPM/o8vlYQ==
signature_date    : 2020-07-04T01:17:49.860773
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,signer,signer_fingerprint,signature_date,signed_attributes



Fichier setup.py :

# -*- coding: utf-8 -*-
from setuphelpers import *
from pyad import pyad
import json

uninstallkey = []


attr = 'macAddress'

def install():
    pass


def update_package():
    from waptpackage import PackageEntry
    import waptguihelper

    pe = PackageEntry()
    pe.load_control_from_wapt(os.getcwd())

    urlserver = inifile_readstring(makepath(install_location('WAPT_is1'),'wapt-get.ini'),'global','wapt_server').replace('https://','')
    credentials_url = waptguihelper.login_password_dialog('Credentials for wapt server',urlserver,'admin','')


    for pc in json.loads(wgets('https://%s:%s@%s/api/v1/hosts?columns=connected_ips,mac_addresses,host_info/computer_ad_dn&limit=10000' % (credentials_url['user'],credentials_url['password'],urlserver)))['result']:
        dn = pc['host_info/computer_ad_dn']
        if not dn:
            continue
        mac = pc['mac_addresses']
        try:
            computer = pyad.from_dn(dn)
        except:
            continue
        if not 'ieee802Device' in computer.get_attribute('objectClass'):
            computer.append_to_attribute('objectClass','ieee802Device')
        print('Add %s to %s in %s' % (mac,attr,dn))
        computer.update_attribute(attr,mac)




if __name__ == '__main__':
    update_package()