python/samdb: add method normalize_dn_in_domain(): get full dn of an relative dn
authorBjörn Baumbach <bb@sernet.de>
Wed, 24 Jan 2018 16:06:50 +0000 (17:06 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 8 Feb 2018 03:58:09 +0000 (04:58 +0100)
Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/samdb.py

index 82eb7a4ef4cf2c3321deccbf23fa05186bce8855..5b04c982673343b18e589f6ff251ff83a26652a6 100644 (file)
@@ -997,3 +997,14 @@ accountExpires: %u
     def allocate_rid(self):
         '''return a new RID from the RID Pool on this DSA'''
         return dsdb._dsdb_allocate_rid(self)
+
+    def normalize_dn_in_domain(self, dn):
+        """return full dn of an relative dn
+
+        :param dn: relative dn
+        """
+        domain_dn = ldb.Dn(self, self.domain_dn())
+        full_dn = ldb.Dn(self, dn)
+        if not full_dn.is_child_of(domain_dn):
+            full_dn.add_base(domain_dn)
+        return full_dn