diff options
author | Tim Potter <tpot@samba.org> | 2005-02-06 04:34:29 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:09:34 -0500 |
commit | 7411bf6775e317a0395178ea829f0db70c942ebb (patch) | |
tree | 6360de16b266e89bced91603bd1fac6ea4e2f0e1 /source4/scripting/swig | |
parent | a54dd495ceb5fb2ebb11c8f56fc9cdfb106bd332 (diff) | |
download | samba-7411bf6775e317a0395178ea829f0db70c942ebb.tar.gz samba-7411bf6775e317a0395178ea829f0db70c942ebb.tar.bz2 samba-7411bf6775e317a0395178ea829f0db70c942ebb.zip |
r5247: Fix rpcclient to work with new swig interface.
(This used to be commit ad12a90d0e0fe7106b1845097d8fc71be3b8e378)
Diffstat (limited to 'source4/scripting/swig')
-rwxr-xr-x | source4/scripting/swig/rpcclient | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/source4/scripting/swig/rpcclient b/source4/scripting/swig/rpcclient index aad4597053..8f33a6133b 100755 --- a/source4/scripting/swig/rpcclient +++ b/source4/scripting/swig/rpcclient @@ -7,6 +7,23 @@ from pprint import pprint import dcerpc, samr +def swig2dict(obj): + """Convert a swig object to a dictionary.""" + + result = {} + + for attr in filter(lambda x: type(x) == str, dir(obj)): + + if attr[:2] == '__' and attr[-2:] == '__': + continue + + if attr == 'this' or attr == 'thisown': + continue + + result[attr] = getattr(obj, attr) + + return result + class rpcclient(Cmd): prompt = 'rpcclient$ ' @@ -67,7 +84,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -89,7 +106,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -110,7 +127,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -121,22 +138,23 @@ class rpcclient(Cmd): else: result = domain_handle.QueryDomainInfo() - pprint(result['info']) + pprint(swig2dict(result)) def do_SamrQueryDomInfo2(self, line): - """Return information about a domain designated by its SID. (Windows 2000 and >)""" + """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): + 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, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -147,7 +165,7 @@ class rpcclient(Cmd): else: result = domain_handle.QueryDomainInfo2() - pprint(result['info']) + pprint(swig2dict(result)) def do_SamrEnumDomainGroups(self, line): """Return the list of groups of a domain designated by its SID.""" @@ -163,7 +181,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -171,11 +189,11 @@ class rpcclient(Cmd): result = domain_handle.EnumDomainGroups() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) def do_SamrEnumDomainAliases(self, line): - """Return the list of aliases (local groups) of a domain designated by its SID.""" + """Return the list of aliases (local groups) of a domain designated + by its SID.""" usage = 'SamrEnumDomainAliases DOMAIN_SID' @@ -188,7 +206,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -196,8 +214,7 @@ class rpcclient(Cmd): result = domain_handle.EnumDomainAliases() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) def do_SamrEnumDomainUsers(self, line): """Return the list of users of a domain designated by its SID.""" @@ -213,7 +230,7 @@ class rpcclient(Cmd): pipe = dcerpc.pipe_connect( self.binding, - dcerpc.DCERPC_SAMR_UUID, dcerpc.DCERPC_SAMR_VERSION, + dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.domain, self.username, self.password) connect_handle = samr.Connect(pipe) @@ -224,8 +241,7 @@ class rpcclient(Cmd): else: result = domain_handle.EnumDomainUsers() - for r in result['sam']['entries']: - print r['name']['name'] + pprint(result) if __name__ == '__main__': |