summaryrefslogtreecommitdiff
path: root/source4/scripting/swig/rpcclient
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-11-07 01:11:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:36 -0500
commite34ee4fdaa4f8b6ae7167b663c2acda2654f2895 (patch)
tree55141d36380880db4ece7658b1bbda360d66521c /source4/scripting/swig/rpcclient
parent6c32daf320b1c70db38199ffcdb0e1c25a207a13 (diff)
downloadsamba-e34ee4fdaa4f8b6ae7167b663c2acda2654f2895.tar.gz
samba-e34ee4fdaa4f8b6ae7167b663c2acda2654f2895.tar.bz2
samba-e34ee4fdaa4f8b6ae7167b663c2acda2654f2895.zip
r3590: Add some more commands to rpcclient from a patch by jbm. Add
SamrQueryDomInfo, SamrQueryDomInfo2, SamrEnumDomainAliases, and SamrEnumDomainUsers. (This used to be commit 91eb405354a65bfd94bf59c21fe21f68fff7b9fd)
Diffstat (limited to 'source4/scripting/swig/rpcclient')
-rwxr-xr-xsource4/scripting/swig/rpcclient133
1 files changed, 132 insertions, 1 deletions
diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient
index 2a3d12cc8e..aad4597053 100755
--- a/source4/scripting/swig/rpcclient
+++ b/source4/scripting/swig/rpcclient
@@ -3,7 +3,7 @@
import sys, os, string
from cmd import Cmd
from optparse import OptionParser
-
+from pprint import pprint
import dcerpc, samr
@@ -96,6 +96,137 @@ class rpcclient(Cmd):
print connect_handle.LookupDomain(args[0])
+ def do_SamrQueryDomInfo(self, line):
+ """Return information about a domain designated by its SID."""
+
+ usage = 'SamrQueryDomInfo DOMAIN_SID [info_level]'
+
+ parser = OptionParser(usage)
+ options, args = parser.parse_args(string.split(line))
+
+ if (len(args) == 0) or (len(args) > 2):
+ print 'usage:', usage
+ return
+
+ pipe = dcerpc.pipe_connect(
+ self.binding,
+ dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION,
+ self.domain, self.username, self.password)
+
+ connect_handle = samr.Connect(pipe)
+ domain_handle = connect_handle.OpenDomain(args[0])
+
+ if (len(args) == 2):
+ result = domain_handle.QueryDomainInfo(int(args[1]))
+ else:
+ result = domain_handle.QueryDomainInfo()
+
+ pprint(result['info'])
+
+ def do_SamrQueryDomInfo2(self, line):
+ """Return information about a domain designated by its SID. (Windows 2000 and >)"""
+
+ usage = 'SamrQueryDomInfo2 DOMAIN_SID [info_level] (Windows 2000 and >)'
+ parser = OptionParser(usage)
+ options, args = parser.parse_args(string.split(line))
+
+ if (len(args) == 0) or (len(args) > 2):
+ print 'usage:', usage
+ return
+
+ pipe = dcerpc.pipe_connect(
+ self.binding,
+ dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION,
+ self.domain, self.username, self.password)
+
+ connect_handle = samr.Connect(pipe)
+ domain_handle = connect_handle.OpenDomain(args[0])
+
+ if (len(args) == 2):
+ result = domain_handle.QueryDomainInfo2(int(args[1]))
+ else:
+ result = domain_handle.QueryDomainInfo2()
+
+ pprint(result['info'])
+
+ def do_SamrEnumDomainGroups(self, line):
+ """Return the list of groups of a domain designated by its SID."""
+
+ usage = 'SamrEnumDomainGroups DOMAIN_SID'
+
+ parser = OptionParser(usage)
+ options, args = parser.parse_args(string.split(line))
+
+ if len(args) != 1:
+ print 'usage:', usage
+ return
+
+ pipe = dcerpc.pipe_connect(
+ self.binding,
+ dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION,
+ self.domain, self.username, self.password)
+
+ connect_handle = samr.Connect(pipe)
+ domain_handle = connect_handle.OpenDomain(args[0])
+
+ result = domain_handle.EnumDomainGroups()
+
+ for r in result['sam']['entries']:
+ print r['name']['name']
+
+ def do_SamrEnumDomainAliases(self, line):
+ """Return the list of aliases (local groups) of a domain designated by its SID."""
+
+ usage = 'SamrEnumDomainAliases DOMAIN_SID'
+
+ parser = OptionParser(usage)
+ options, args = parser.parse_args(string.split(line))
+
+ if len(args) != 1:
+ print 'usage:', usage
+ return
+
+ pipe = dcerpc.pipe_connect(
+ self.binding,
+ dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION,
+ self.domain, self.username, self.password)
+
+ connect_handle = samr.Connect(pipe)
+ domain_handle = connect_handle.OpenDomain(args[0])
+
+ result = domain_handle.EnumDomainAliases()
+
+ for r in result['sam']['entries']:
+ print r['name']['name']
+
+ def do_SamrEnumDomainUsers(self, line):
+ """Return the list of users of a domain designated by its SID."""
+
+ usage = 'SamrEnumDomainUsers DOMAIN_SID [user_account_flags]'
+
+ parser = OptionParser(usage)
+ options, args = parser.parse_args(string.split(line))
+
+ if (len(args) == 0) or (len(args) > 2):
+ print 'usage:', usage
+ return
+
+ pipe = dcerpc.pipe_connect(
+ self.binding,
+ dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION,
+ self.domain, self.username, self.password)
+
+ connect_handle = samr.Connect(pipe)
+ domain_handle = connect_handle.OpenDomain(args[0])
+
+ if (len(args) == 2):
+ result = domain_handle.EnumDomainUsers(int(args[1]))
+ else:
+ result = domain_handle.EnumDomainUsers()
+
+ for r in result['sam']['entries']:
+ print r['name']['name']
+
if __name__ == '__main__':
# Parse command line