Nicht für produktiven Einstz geeignet! Script enthält keinerlei Fehlerbehandlung.
#!/usr/bin/python # -*- coding: utf-8 -*- import ldap from pprint import pprint LDAP_USER = '<USER>@<DOMAIN>' LDAP_PASSWORD = '<PASSWORD>' LDAP_SERVER = 'ldap://<LDAP_SERVER>' LDAP_BASE = 'dc=<DOMAIN>,dc=<TLD>' ALIASES = [] ########################################################### def add_alias(ALIAS): ALIAS = ALIAS.lower() if '@' in ALIAS: ALIAS = ALIAS.replace('smtp:','') if not ALIAS in ALIASES: ALIASES.append(ALIAS) def analyze_search(LDAP_SEARCH): for DN,ENTRY in LDAP_SEARCH: if DN != None and ENTRY: if 'proxyAddresses' in ENTRY: for ALIAS in ENTRY['proxyAddresses']: add_alias(ALIAS) if 'mail' in ENTRY: for ALIAS in ENTRY['mail']: add_alias(ALIAS) if 'msExchShadowProxyAddresses' in ENTRY: for ALIAS in ENTRY['msExchShadowProxyAddresses']: add_alias(ALIAS) ########################################################### LDAP = ldap.initialize(LDAP_SERVER) LDAP.simple_bind_s(LDAP_USER,LDAP_PASSWORD) LDAP_SEARCH = LDAP.search_s(LDAP_BASE,ldap.SCOPE_SUBTREE,'(&(|(objectClass=user)(objectClass=group))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))',['msExchShadowProxyAddresses','proxyAddresses','mail']) analyze_search(LDAP_SEARCH) ########################################################### ALIASES.sort() pprint(ALIASES) print "Count of aliases: ", len(ALIASES)