s4-dsdb: Added python helpers for getting and seting dSHeuristics to SamDB
authorNadezhda Ivanova <nivanova@samba.org>
Tue, 23 Nov 2010 09:20:12 +0000 (11:20 +0200)
committerNadezhda Ivanova <nivanova@samba.org>
Tue, 23 Nov 2010 09:22:26 +0000 (11:22 +0200)
source4/scripting/python/samba/samdb.py

index 460c8b898cb217e896e8635b2d1cd2286c5083e6..7bc461a0306e82eac674e2456658a5486b692464 100644 (file)
@@ -617,3 +617,27 @@ accountExpires: %u
             return None
         else:
             return res[0]["minPwdAge"][0]
+
+    def set_dsheuristics(self, dsheuristics):
+        m = ldb.Message()
+        m.dn = ldb.Dn(self, "CN=Directory Service,CN=Windows NT,CN=Services,%s"
+                      % self.get_config_basedn().get_linearized())
+        if dsheuristics is not None:
+            m["dSHeuristics"] = ldb.MessageElement(dsheuristics, ldb.FLAG_MOD_REPLACE,
+                                               "dSHeuristics")
+        else:
+            m["dSHeuristics"] = ldb.MessageElement([], ldb.FLAG_MOD_DELETE, "dSHeuristics")
+        self.modify(m)
+
+    def get_dsheuristics(self):
+        res = self.search("CN=Directory Service,CN=Windows NT,CN=Services,%s"
+                          % self.get_config_basedn().get_linearized(),
+                          scope=ldb.SCOPE_BASE, attrs=["dSHeuristics"])
+        if len(res) == 0:
+            dsheuristics = None
+        elif "dSHeuristics" in res[0]:
+            dsheuristics = res[0]["dSHeuristics"][0]
+        else:
+            dsheuristics = None
+
+        return dsheuristics