diff options
author | Tim Potter <tpot@samba.org> | 2005-05-01 02:40:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:16:24 -0500 |
commit | 9d87efb681c73e892c8690679238b9dc1d971a9c (patch) | |
tree | f7aaae4d6f9e8d41322e442bf5a9a1cf33742aa2 /source4/scripting/swig | |
parent | 5c6e1f81cec532e075f2d9e7eab25794a6b10bf7 (diff) | |
download | samba-9d87efb681c73e892c8690679238b9dc1d971a9c.tar.gz samba-9d87efb681c73e892c8690679238b9dc1d971a9c.tar.bz2 samba-9d87efb681c73e892c8690679238b9dc1d971a9c.zip |
r6540: Implement a bunch more SAMR functions.
(This used to be commit 7ab240644ec6cfd0449df7e2dfe0eb1b8a52ccdb)
Diffstat (limited to 'source4/scripting/swig')
-rw-r--r-- | source4/scripting/swig/dcerpc.i | 1 | ||||
-rw-r--r-- | source4/scripting/swig/samr.py | 117 | ||||
-rwxr-xr-x | source4/scripting/swig/torture/torture_samr.py | 40 |
3 files changed, 139 insertions, 19 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index e41d9e4e2f..60e661f180 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -231,6 +231,7 @@ char *nt_errstr(NTSTATUS nt_code); %array_functions(struct samr_String, samr_String_array); %array_functions(struct samr_SamEntry, samr_SamEntry_array); %array_functions(union samr_ConnectInfo, samr_ConnectInfo_array); +%array_functions(struct samr_RidType, samr_RidType_array); %array_functions(struct lsa_SidPtr, lsa_SidPtr_array); diff --git a/source4/scripting/swig/samr.py b/source4/scripting/swig/samr.py index c254acd11b..314f78b8ad 100644 --- a/source4/scripting/swig/samr.py +++ b/source4/scripting/swig/samr.py @@ -17,7 +17,6 @@ def sid_to_string(sid): return result - def string_to_sid(string): """Convert a string SID to a Python dictionary SID. Throws a ValueError if the SID string was badly formed.""" @@ -88,7 +87,6 @@ def string_to_sid(string): return sid - def call_fn(fn, pipe, args): """Wrap up a RPC call and throw an exception is an error was returned.""" @@ -98,8 +96,7 @@ def call_fn(fn, pipe, args): raise dcerpc.NTSTATUS(result, dcerpc.nt_errstr(result)); return result; - - + class SamrHandle: def __init__(self, pipe, handle): @@ -139,7 +136,6 @@ class SamrHandle: r.data_in.sdbuf = sdbuf call_fn(dcerpc.dcerpc_samr_SetSecurity, self.pipe, r) - class ConnectHandle(SamrHandle): @@ -206,6 +202,16 @@ class ConnectHandle(SamrHandle): return r.data_out.info + def SetBootKeyInformation(self, unknown1, unknown2, unknown3): + + r = dcerpc.samr_GetBootKeyInformation() + r.data_in.connect_handle = self.handle + r.data_in.unknown1 = unknown1 + r.data_in.unknown2 = unknown2 + r.data_in.unknown3 = unknown3 + + call_fn(dcerpc.dcerpc_samr_SetBootKeyInformation, self.pipe, r) + class DomainHandle(SamrHandle): def QueryDomainInfo(self, level = 2): @@ -402,8 +408,10 @@ class DomainHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_LookupNames, self.pipe, r) - return ([dcerpc.uint32_array_getitem(r.data_out.rids.ids, i) for i in range(r.data_out.rids.count)], - [dcerpc.uint32_array_getitem(r.data_out.types.ids, i) for i in range(r.data_out.types.count)]) + return ([dcerpc.uint32_array_getitem(r.data_out.rids.ids, i) + for i in range(r.data_out.rids.count)], + [dcerpc.uint32_array_getitem(r.data_out.types.ids, i) + for i in range(r.data_out.types.count)]) def CreateDomainGroup(self, domain_name, access_mask = 0x02000000): @@ -486,6 +494,28 @@ class DomainHandle(SamrHandle): return getattr(r.data_out.info, 'info%d' % level) + def GetBootKeyInformation(self): + + r = dcerpc.samr_GetBootKeyInformation() + r.data_in.domain_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetBootKeyInformation, self.pipe, r) + + return r.data_out.unknown + + def SetBootKeyInformation(self): + + r = dcerpc.samr_GetBootKeyInformation() + r.data_in.domain_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetBootKeyInformation, self.pipe, r) + + def TestPrivateFunctionsDomain(self): + + r = dcerpc.samr_TestPrivateFunctionsDomain() + r.data_in.domain_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsDomain, self.pipe, r) class UserHandle(SamrHandle): @@ -527,10 +557,57 @@ class UserHandle(SamrHandle): return r.data_out.info + def GetGroupsForUser(self): + + r = dcerpc.samr_GetGroupsForUser() + r.data_in.user_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetGroupsForUser, self.pipe, r) + + rid_types = [dcerpc.samr_RidType_array_getitem(r.data_out.rids.rid, x) + for x in range(r.data_out.rids.count)] + + return [(x.rid, x.type) for x in rid_types] + + def TestPrivateFunctionsUser(self): + + r = dcerpc.samr_TestPrivateFunctionsUser() + r.data_in.user_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsUser, self.pipe, r) + class GroupHandle(SamrHandle): - pass - + def QueryGroupInfo(self, level): + + r = dcerpc.samr_QueryGroupInfo() + r.data_in.group_handle = self.handle + r.data_in.level = level + + call_fn(dcerpc.dcerpc_samr_QueryGroupInfo, self.pipe, r) + + return r.data_out.info + + def SetGroupInfo(self, level, info): + + r = dcerpc.samr_SetGroupInfo() + r.data_in.group_handle = self.handle + r.data_in.level = level + r.data_in.info = info + + call_fn(dcerpc.dcerpc_samr_SetGroupInfo, self.pipe, r) + + def QueryGroupMember(self): + + r = dcerpc.samr_QueryGroupMember() + r.data_in.group_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_QueryGroupMember, self.pipe, r) + + return [(dcerpc.uint32_array_getitem(r.data_out.rids.rids, x), + dcerpc.uint32_array_getitem(r.data_out.rids.unknown, x)) + for x in range(r.data_out.rids.count)] + class AliasHandle(SamrHandle): def DeleteDomAlias(self): @@ -584,6 +661,18 @@ class AliasHandle(SamrHandle): call_fn(dcerpc.dcerpc_samr_AddMultipleMembersToAlias, self.pipe, r) + def GetMembersInAlias(self): + + r = dcerpc.samr_GetMembersInAlias() + r.data_in.alias_handle = self.handle + + call_fn(dcerpc.dcerpc_samr_GetMembersInAlias, self.pipe, r) + + return [ + sid_to_string( + dcerpc.lsa_SidPtr_array_getitem(r.data_out.sids.sids, x).sid) + for x in range(r.data_out.sids.num_sids)] + def Connect(pipe, access_mask = 0x02000000): r = dcerpc.samr_Connect() @@ -595,7 +684,6 @@ def Connect(pipe, access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) - def Connect2(pipe, system_name = '', access_mask = 0x02000000): """Connect to the SAMR pipe.""" @@ -607,7 +695,6 @@ def Connect2(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) - def Connect3(pipe, system_name = '', access_mask = 0x02000000): r = dcerpc.samr_Connect3() @@ -645,30 +732,22 @@ def Connect5(pipe, system_name = '', access_mask = 0x02000000): return ConnectHandle(pipe, r.data_out.connect_handle) -# QueryGroupInfo -# SetGroupInfo # AddGroupMember # DeleteDomainGroup # DeleteGroupMember -# QueryGroupMember # SetMemberAttributesofGroup # AddAliasMember # DeleteAliasMember # GetMembersinAlias # SetUserInfo # ChangePasswordUser -# GetGroupsForUser # GetDisplayEnumerationIndex -# TestPrivateFunctionsDomain -# TestPrivateFunctionsUser # RemoveMemberFromForeignDomain # GetDisplayEnumerationIndex2 # RemoveMultipleMembersFromAlias # OemChangePasswordUser2 # ChangePasswordUser2 # SetUserInfo2 -# SetBootKeyInformation -# GetBootKeyInformation # ChangePasswordUser3 # SetDsrmPassword # ValidatePassword diff --git a/source4/scripting/swig/torture/torture_samr.py b/source4/scripting/swig/torture/torture_samr.py index 9025fdd978..15c6dc1a76 100755 --- a/source4/scripting/swig/torture/torture_samr.py +++ b/source4/scripting/swig/torture/torture_samr.py @@ -42,18 +42,43 @@ def test_UserHandle(user_handle): if arg[0] != 0xc0000003L: # NT_STATUS_INVALID_INFO_CLASS raise + # GetGroupsForUser() + + user_handle.GetGroupsForUser() + + # TestPrivateFunctionsUser() + + try: + user_handle.TestPrivateFunctionsUser() + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xC0000002L: + raise + def test_GroupHandle(group_handle): # QuerySecurity()/SetSecurity() group_handle.SetSecurity(group_handle.QuerySecurity()) + # QueryGroupInfo() + + for level in [1, 2, 3, 4, 5]: + info = group_handle.QueryGroupInfo(level) + + # TODO: SetGroupinfo() + + # QueryGroupMember() + + group_handle.QueryGroupMember() + def test_AliasHandle(alias_handle): # QuerySecurity()/SetSecurity() alias_handle.SetSecurity(alias_handle.QuerySecurity()) + print alias_handle.GetMembersInAlias() + def test_DomainHandle(name, sid, domain_handle): print 'testing %s (%s)' % (name, sid) @@ -142,6 +167,21 @@ def test_DomainHandle(name, sid, domain_handle): # CreateDomainGroup # GetAliasMembership + # GetBootKeyInformation() + + try: + domain_handle.GetBootKeyInformation() + except dcerpc.NTSTATUS, arg: + pass + + # TestPrivateFunctionsDomain() + + try: + domain_handle.TestPrivateFunctionsDomain() + except dcerpc.NTSTATUS, arg: + if arg[0] != 0xC0000002L: + raise + def test_ConnectHandle(connect_handle): print 'testing connect handle' |