s4:netcmd/common.py: add a "netcmd" function to do a cldap netlogon request
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Tue, 22 Nov 2011 21:26:38 +0000 (22:26 +0100)
committerStefan Metzmacher <metze@samba.org>
Sun, 27 Nov 2011 11:50:06 +0000 (12:50 +0100)
This is useful for a new "samba-tool domain info" command.

Patch inspired by Matthieu Patou.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source4/scripting/python/samba/netcmd/common.py

index cc97fc523fb7f0580c7876d7bc82de612acea023..9291f872aba196ad3fb95549271e2623217dc3dd 100644 (file)
@@ -62,3 +62,12 @@ def netcmd_finddc(lp, creds, realm=None):
     cldap_ret = net.finddc(domain=realm,
                 flags=nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS | nbt.NBT_SERVER_WRITABLE)
     return cldap_ret.pdc_dns_name
+
+
+def netcmd_get_domain_infos_via_cldap(lp, creds, address=None):
+    '''Return domain informations (CLDAP record) of the ldap-capable
+       DC with the specified address'''
+    net = Net(creds=creds, lp=lp)
+    cldap_ret = net.finddc(address=address,
+                flags=nbt.NBT_SERVER_LDAP | nbt.NBT_SERVER_DS)
+    return cldap_ret