summaryrefslogtreecommitdiff
path: root/source4/scripting/swig/rpcclient
diff options
context:
space:
mode:
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