From 1cf46d2e35c3c290a3d7d1c57d622a2abf2643e6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 11 Apr 2013 17:12:09 +0930 Subject: source4/scripting/python/samba/samba3: handle ntdb files. Upgrading old Samba 3 instances seems like a place where we don't have to read ntdb files, but Andrew Bartlett points out that you can run a Samba 4.0 and even a 4.1 'classic' domain and desire to migrate that to the AD DC. So make this upgrade code generic: if it finds an ntdb file, read that, otherwise read the tdb file. Cc: Jelmer Vernooij Signed-off-by: Rusty Russell Reviewed-by: Jeremy Allison --- python/samba/samba3/__init__.py | 98 +++++++++++++++++++++-------------------- python/samba/tests/samba3.py | 4 +- 2 files changed, 53 insertions(+), 49 deletions(-) (limited to 'python') diff --git a/python/samba/samba3/__init__.py b/python/samba/samba3/__init__.py index acccff4e29..0165909f45 100644 --- a/python/samba/samba3/__init__.py +++ b/python/samba/samba3/__init__.py @@ -25,37 +25,41 @@ REGISTRY_DB_VERSION = 1 import os import struct import tdb +import ntdb import passdb import param as s3param -def fetch_uint32(tdb, key): +def fetch_uint32(db, key): try: - data = tdb[key] + data = db[key] except KeyError: return None assert len(data) == 4 return struct.unpack("