Détails du package smp-add-macaddress-computer-ad_5_all_UPDATE_PACKAGE_ONLY.wapt
retour Revenir à la liste des packages

smp-add-macaddress-computer-ad

ATTENTION CE DÉPÔT n'est plus compatible 1.3 vous devez migrer en 1.5.1.21 !

Fichier control :

package           : smp-add-macaddress-computer-ad
version           : 5
architecture      : all
section           : base
priority          : optional
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    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 5a95d133-f296-4fb6-ba76-d357f79e0a35
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 8da83ebdac1a25e820b186510d049f47407b11835b0664fdc5bacd3595b1671d
signature         : olnILibi64Jaas3p7YKaDpufUfhTrpUSzDbNIUkq6kPn40WZScU5WoZ6418hr7Cnxj9ZsqkDvwqgBGDI/DrYyY4cVNO4h+IBV6b8xOxHdYX/iBk4Zwm4NZBiK7oIruwBbZqRRkEFYkzgy1XHI256LooxtqtMmmpQo18ZKAkY6ZWgAu7jRQsbk9H38t12S/iIv5lD0PrqY6kXEUfiwPDxPMgD1+O6pNy3JaDsDtlHS8ie2UIv9NFzqVjO41tPOxgqkabs/B+Y/R3WFkS5+zPgKNN8coyyaFeIlQJh7ocS+s53kqdIVyu8JIGZn08xd+gxGncFToY4DJbxCeCFq+QsRw==
signature_date    : 20190121-155925
signed_attributes : package,version,architecture,section,priority,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,audit_schedule,editor,keywords,licence,homepage,package_uuid,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()