summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2011-08-18 15:15:20 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-08-19 16:35:04 +1000
commit57b9f1b5025f2b521e6d8bcb25762b223b83ace4 (patch)
treea53d8f2122d230775f86188b012eb1c4876c52c3 /source4/scripting/python
parentc71e781e7d66022cd6181e910f5fb8b7d750cbc1 (diff)
downloadsamba-57b9f1b5025f2b521e6d8bcb25762b223b83ace4.tar.gz
samba-57b9f1b5025f2b521e6d8bcb25762b223b83ace4.tar.bz2
samba-57b9f1b5025f2b521e6d8bcb25762b223b83ace4.zip
samba3-python: Add methods to get any entry (user/group) and its sid from idmap
This is required in upgrade_s3 script to migrate idmap database from s3 to s4 Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/samba3/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/samba3/__init__.py b/source4/scripting/python/samba/samba3/__init__.py
index 55e9b18f24..f5dde44aa0 100644
--- a/source4/scripting/python/samba/samba3/__init__.py
+++ b/source4/scripting/python/samba/samba3/__init__.py
@@ -208,6 +208,14 @@ class IdmapDatabase(TdbDatabase):
def _check_version(self):
assert fetch_int32(self.tdb, "IDMAP_VERSION\0") == IDMAP_VERSION_V2
+ def ids(self):
+ """Retrieve a list of all ids in this database."""
+ for k in self.tdb.iterkeys():
+ if k.startswith(IDMAP_USER_PREFIX):
+ yield k.rstrip("\0").split(" ")
+ if k.startswith(IDMAP_GROUP_PREFIX):
+ yield k.rstrip("\0").split(" ")
+
def uids(self):
"""Retrieve a list of all uids in this database."""
for k in self.tdb.iterkeys():
@@ -220,6 +228,12 @@ class IdmapDatabase(TdbDatabase):
if k.startswith(IDMAP_GROUP_PREFIX):
yield int(k[len(IDMAP_GROUP_PREFIX):].rstrip("\0"))
+ def get_sid(self, xid, id_type):
+ data = self.tdb.get("%s %s\0" % (id_type, str(xid)))
+ if data is None:
+ return data
+ return data.rstrip("\0")
+
def get_user_sid(self, uid):
"""Retrieve the SID associated with a particular uid.