s4-pysamdb: fixed the normalisation of grouptype in group add
authorAndrew Tridgell <tridge@samba.org>
Fri, 17 Jun 2011 02:02:23 +0000 (12:02 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 17 Jun 2011 03:43:18 +0000 (05:43 +0200)
ldap integers are signed

Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Fri Jun 17 05:43:18 CEST 2011 on sn-devel-104

source4/scripting/python/samba/samdb.py

index b513ac8fff224bd0bd3ce83a7221631fcd7c2f0a..53346e867031f5dd16f62741bd2756d8188339f6 100644 (file)
@@ -142,7 +142,7 @@ pwdLastSet: 0
             "objectClass": "group"}
 
         if grouptype is not None:
-            ldbmessage["groupType"] = "%d" % grouptype
+            ldbmessage["groupType"] = self.normalise_int32(grouptype)
 
         if description is not None:
             ldbmessage["description"] = description
@@ -722,3 +722,9 @@ 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)