6 def test_Connect(pipe):
8 handle = samr.Connect(pipe)
9 handle = samr.Connect2(pipe)
10 handle = samr.Connect3(pipe)
11 handle = samr.Connect4(pipe)
16 handle = samr.Connect5(pipe)
17 except dcerpc.NTSTATUS, arg:
18 if arg[0] != 0xc00000d2L: # NT_STATUS_NET_WRITE_FAULT
23 def test_UserHandle(user_handle):
25 # QuerySecurity()/SetSecurity()
27 user_handle.SetSecurity(user_handle.QuerySecurity())
31 user_handle.GetUserPwInfo()
35 for level in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20,
39 user_handle.QueryUserInfo(level)
40 user_handle.QueryUserInfo2(level)
41 except dcerpc.NTSTATUS, arg:
42 if arg[0] != 0xc0000003L: # NT_STATUS_INVALID_INFO_CLASS
47 user_handle.GetGroupsForUser()
49 # TestPrivateFunctionsUser()
52 user_handle.TestPrivateFunctionsUser()
53 except dcerpc.NTSTATUS, arg:
54 if arg[0] != 0xC0000002L:
57 def test_GroupHandle(group_handle):
59 # QuerySecurity()/SetSecurity()
61 group_handle.SetSecurity(group_handle.QuerySecurity())
65 for level in [1, 2, 3, 4, 5]:
66 info = group_handle.QueryGroupInfo(level)
68 # TODO: SetGroupinfo()
72 group_handle.QueryGroupMember()
74 def test_AliasHandle(alias_handle):
76 # QuerySecurity()/SetSecurity()
78 alias_handle.SetSecurity(alias_handle.QuerySecurity())
80 print alias_handle.GetMembersInAlias()
82 def test_DomainHandle(name, sid, domain_handle):
84 print 'testing %s (%s)' % (name, sid)
86 # QuerySecurity()/SetSecurity()
88 domain_handle.SetSecurity(domain_handle.QuerySecurity())
90 # LookupNames(), none mapped
93 domain_handle.LookupNames(['xxNONAMExx'])
94 except dcerpc.NTSTATUS, arg:
95 if arg[0] != 0xc0000073L:
96 raise dcerpc.NTSTATUS(arg)
98 # LookupNames(), some mapped
100 if name != 'Builtin':
101 domain_handle.LookupNames(['Administrator', 'xxNONAMExx'])
103 # QueryDomainInfo()/SetDomainInfo()
105 levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13]
106 set_ok = [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0]
108 for i in range(len(levels)):
110 info = domain_handle.QueryDomainInfo(level = levels[i])
113 domain_handle.SetDomainInfo(levels[i], info)
114 except dcerpc.NTSTATUS, arg:
115 if not (arg[0] == 0xc0000003L and not set_ok[i]):
120 levels = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13]
122 for i in range(len(levels)):
123 domain_handle.QueryDomainInfo2(level = levels[i])
127 print 'testing users'
129 users = domain_handle.EnumDomainUsers()
130 rids = domain_handle.LookupNames(users)
132 for i in range(len(users)):
133 test_UserHandle(domain_handle.OpenUser(rids[0][i]))
137 for i in [1, 2, 3, 4, 5]:
138 domain_handle.QueryDisplayInfo(level = i)
139 domain_handle.QueryDisplayInfo2(level = i)
140 domain_handle.QueryDisplayInfo3(level = i)
144 print 'testing groups'
146 groups = domain_handle.EnumDomainGroups()
147 rids = domain_handle.LookupNames(groups)
149 for i in range(len(groups)):
150 test_GroupHandle(domain_handle.OpenGroup(rids[0][i]))
154 print 'testing aliases'
156 aliases = domain_handle.EnumDomainAliases()
157 rids = domain_handle.LookupNames(aliases)
159 for i in range(len(aliases)):
160 test_AliasHandle(domain_handle.OpenAlias(rids[0][i]))
166 # RemoveMemberFromForeignDomain
170 # GetBootKeyInformation()
173 domain_handle.GetBootKeyInformation()
174 except dcerpc.NTSTATUS, arg:
177 # TestPrivateFunctionsDomain()
180 domain_handle.TestPrivateFunctionsDomain()
181 except dcerpc.NTSTATUS, arg:
182 if arg[0] != 0xC0000002L:
185 def test_ConnectHandle(connect_handle):
187 print 'testing connect handle'
189 # QuerySecurity/SetSecurity
191 connect_handle.SetSecurity(connect_handle.QuerySecurity())
193 # Lookup bogus domain
196 connect_handle.LookupDomain('xxNODOMAINxx')
197 except dcerpc.NTSTATUS, arg:
198 if arg[0] != 0xC00000DFL: # NT_STATUS_NO_SUCH_DOMAIN
203 for domain_name in connect_handle.EnumDomains():
205 connect_handle.GetDomPwInfo(domain_name)
206 sid = connect_handle.LookupDomain(domain_name)
207 domain_handle = connect_handle.OpenDomain(sid)
209 test_DomainHandle(domain_name, sid, domain_handle)
211 # TODO: Test Shutdown() function
213 def runtests(binding, creds):
215 print 'Testing SAMR pipe'
217 pipe = dcerpc.pipe_connect(binding,
218 dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), creds)
220 handle = test_Connect(pipe)
221 test_ConnectHandle(handle)