Initial code to generate HOIP Subscriber list - replacement for

Hamshack Hotline.
This commit is contained in:
Ed Braaten 2025-11-22 21:06:17 -08:00
parent 334b5f22eb
commit ac8ecbdda4
No known key found for this signature in database
GPG key ID: 11743CE9834B8FA6
3 changed files with 6259 additions and 0 deletions

56
hoipdownload.py Normal file
View file

@ -0,0 +1,56 @@
from ldap3 import Server, Connection, ALL, SUBTREE
import pandas as pd
# LDAP connection details from the wiki
server_url = 'ldap://207.246.98.219:389' # Server and port (no TLS, as per "TLS Mode: LDAP or No" use 'ldaps://' if TLS needed)
search_base = 'ou=people,dc=hamsoverip,dc=com'
search_filter = '(telephoneNumber=*)' # Fetch all entries with an extension; adjust if needed, e.g., '(objectClass=person)'
attributes = ['cn', 'sn', 'telephoneNumber'] # Key attributes; add more if you discover others like 'callsign'
# Connect anonymously (no auth)
server = Server(server_url, get_info=ALL)
conn = Connection(server, auto_bind=True) # No user/password
# Perform the search
conn.search(
search_base=search_base,
search_filter=search_filter,
search_scope=SUBTREE,
attributes=attributes
)
# Extract data
data = []
for entry in conn.entries:
extension = entry.telephoneNumber.value if 'telephoneNumber' in entry else ''
cn_value = entry.cn.value if 'cn' in entry else ''
sn_value = entry.sn.value if 'sn' in entry else ''
# clean up data
hoipnumber = extension.partition(' ')[0]
callsign = cn_value.partition(' ')[0]
hamname = sn_value.partition(' ')[0]
if hoipnumber: # Only include entries with extensions
data.append({
'HOIP Extension': hoipnumber,
'Call': callsign,
'Name': hamname # Include raw for reference
})
# Save to CSV
if data:
df = pd.DataFrame(data)
# CSV output for debugging...
df.to_csv('hoip_subscribers.csv', index=False)
print(f'Saved {len(data)} entries to hoip_subscribers.csv')
# Excel output for production...
df.to_excel('hoip_subscribers.xlsx', index=False)
print(f'Saved {len(data)} entries to hoip_subscribers.xlsx')
else:
print('No entries found check filter or connection.')
# Unbind
conn.unbind()