pysamdb: move normalise_int32() to common module
authorAndrew Tridgell <tridge@samba.org>
Fri, 5 Aug 2011 01:17:06 +0000 (11:17 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 9 Aug 2011 09:56:23 +0000 (11:56 +0200)
this will be needed in quite a few places

source4/scripting/python/samba/common.py
source4/scripting/python/samba/samdb.py

index 6eeace594359e4ab41a3a9a2762f9d67827c8269..867f44a116398ce29a6f94edaf6e7acdb46f16ff 100644 (file)
@@ -50,3 +50,8 @@ def confirm(msg, forced = False, allow_all=False):
         print("Unknown response '%s'" % v)
 
 
+def normalise_int32(ivalue):
+    '''normalise a ldap integer to signed 32 bit'''
+    if int(ivalue) & 0x80000000:
+        return str(int(ivalue) - 0x100000000)
+    return str(ivalue)
index 8a12c9746a717930896ee5bdec6c3c64fc1c5ee9..46a7fea32e3b10b98ffc525483717adf9498b875 100644 (file)
@@ -30,6 +30,7 @@ import base64
 from samba import dsdb
 from samba.ndr import ndr_unpack, ndr_pack
 from samba.dcerpc import drsblobs, misc
+from samba.common import normalise_int32
 
 __docformat__ = "restructuredText"
 
@@ -170,7 +171,7 @@ pwdLastSet: 0
             "objectClass": "group"}
 
         if grouptype is not None:
-            ldbmessage["groupType"] = self.normalise_int32(grouptype)
+            ldbmessage["groupType"] = normalise_int32(grouptype)
 
         if description is not None:
             ldbmessage["description"] = description
@@ -774,9 +775,3 @@ accountExpires: %u
         if sd:
             m["nTSecurityDescriptor"] = ndr_pack(sd)
         self.add(m)
-
-    def normalise_int32(self, ivalue):
-        '''normalise a ldap integer to signed 32 bit'''
-        if int(ivalue) & 0x80000000:
-            return str(int(ivalue) - 0x100000000)
-        return str(ivalue)