[PATCH] s4: Create helpers functions related to provision
Matthieu Patou
mat at matws.net
Wed Aug 26 10:30:15 MDT 2009
One for getting attributes with DN syntax, one for getting forward linked attributes
and one for getting the list of partition
---
source4/scripting/python/samba/provision.py | 45 +++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 0a3a44f..2ae8510 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -1839,4 +1839,49 @@ def create_krb5_conf(path, setup_path, dnsdomain, hostname, realm):
+def get_linked_attributes(schemadn,schemaldb):
+ attrs = ["linkID", "lDAPDisplayName"]
+ res = schemaldb.search(expression="(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
+ attributes = []
+ for i in range (0, len(res)):
+ expression = "(&(objectclass=attributeSchema)(linkID=%d)(attributeSyntax=2.5.5.1))" % (int(res[i]["linkID"][0])+1)
+ target = schemaldb.searchone(basedn=schemadn,
+ expression=expression,
+ attribute="lDAPDisplayName",
+ scope=SCOPE_SUBTREE)
+ if target is not None:
+ attributes.append(str(res[i]["lDAPDisplayName"]))
+
+ return attributes
+
+def get_dnsyntax_attributes(schemadn,schemaldb):
+ attrs = ["linkID", "lDAPDisplayName"]
+ res = schemaldb.search(expression="(&(!(linkID=*))(objectclass=attributeSchema)(attributeSyntax=2.5.5.1))", base=schemadn, scope=SCOPE_ONELEVEL, attrs=attrs)
+ attributes = []
+ for i in range (0, len(res)):
+ attributes.append(str(res[i]["lDAPDisplayName"]))
+
+ return attributes
+
+def get_partitions(credentials,session_info,paths,lp):
+# Get the partitions
+ sam_ldb = Ldb(paths.samdb, session_info=session_info, credentials=credentials,lp=lp)
+ attrs2 = ["namingContexts"]
+ res2 = sam_ldb.search(expression="(objectClass=*)",base="", scope=SCOPE_BASE, attrs=attrs2)
+ partitions = []
+ current = ""
+ rootdn = ""
+ def part_sort(x,y):
+ if (len(x) > len(y)):
+ return 1
+ elif (len(x) < len(y)):
+ return -1
+ else:
+ return 0
+ for i in range (0,len( res2[0]["namingContexts"])):
+ part = str(res2[0]["namingContexts"][i])
+ partitions.append(part)
+ partitions.sort(part_sort)
+
+ return partitions
--
1.6.0.4
--------------090203020906080509050208
Content-Type: text/x-patch;
name="0003-s4-Make-code-reuse-for-get_linked_attributes.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="0003-s4-Make-code-reuse-for-get_linked_attributes.patch"
More information about the samba-technical
mailing list