5 def test_Connect(pipe
):
7 handle
= samr
.Connect(pipe
)
8 handle
= samr
.Connect2(pipe
)
9 handle
= samr
.Connect3(pipe
)
10 handle
= samr
.Connect4(pipe
)
15 handle
= samr
.Connect5(pipe
)
16 except dcerpc
.NTSTATUS
, arg
:
17 if arg
[0] != 0xc00000d2L
: # NT_STATUS_NET_WRITE_FAULT
22 def test_UserHandle(user_handle
):
24 # QuerySecurity()/SetSecurity()
26 user_handle
.SetSecurity(user_handle
.QuerySecurity())
30 user_handle
.GetUserPwInfo()
34 for level
in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20,
38 user_handle
.QueryUserInfo(level
)
39 user_handle
.QueryUserInfo2(level
)
40 except dcerpc
.NTSTATUS
, arg
:
41 if arg
[0] != 0xc0000003L
: # NT_STATUS_INVALID_INFO_CLASS
46 user_handle
.GetGroupsForUser()
48 # TestPrivateFunctionsUser()
51 user_handle
.TestPrivateFunctionsUser()
52 except dcerpc
.NTSTATUS
, arg
:
53 if arg
[0] != 0xC0000002L
:
56 def test_GroupHandle(group_handle
):
58 # QuerySecurity()/SetSecurity()
60 group_handle
.SetSecurity(group_handle
.QuerySecurity())
64 for level
in [1, 2, 3, 4, 5]:
65 info
= group_handle
.QueryGroupInfo(level
)
67 # TODO: SetGroupinfo()
71 group_handle
.QueryGroupMember()
73 def test_AliasHandle(alias_handle
):
75 # QuerySecurity()/SetSecurity()
77 alias_handle
.SetSecurity(alias_handle
.QuerySecurity())
79 print alias_handle
.GetMembersInAlias()
81 def test_DomainHandle(name
, sid
, domain_handle
):
83 print 'testing %s (%s)' % (name
, sid
)
85 # QuerySecurity()/SetSecurity()
87 domain_handle
.SetSecurity(domain_handle
.QuerySecurity())
89 # LookupNames(), none mapped
92 domain_handle
.LookupNames(['xxNONAMExx'])
93 except dcerpc
.NTSTATUS
, arg
:
94 if arg
[0] != 0xc0000073L
:
95 raise dcerpc
.NTSTATUS(arg
)
97 # LookupNames(), some mapped
100 domain_handle
.LookupNames(['Administrator', 'xxNONAMExx'])
102 # QueryDomainInfo()/SetDomainInfo()
104 levels
= [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13]
105 set_ok
= [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0]
107 for i
in range(len(levels
)):
109 info
= domain_handle
.QueryDomainInfo(level
= levels
[i
])
112 domain_handle
.SetDomainInfo(levels
[i
], info
)
113 except dcerpc
.NTSTATUS
, arg
:
114 if not (arg
[0] == 0xc0000003L
and not set_ok
[i
]):
119 levels
= [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13]
121 for i
in range(len(levels
)):
122 domain_handle
.QueryDomainInfo2(level
= levels
[i
])
126 print 'testing users'
128 users
= domain_handle
.EnumDomainUsers()
129 rids
= domain_handle
.LookupNames(users
)
131 for i
in range(len(users
)):
132 test_UserHandle(domain_handle
.OpenUser(rids
[0][i
]))
136 for i
in [1, 2, 3, 4, 5]:
137 domain_handle
.QueryDisplayInfo(level
= i
)
138 domain_handle
.QueryDisplayInfo2(level
= i
)
139 domain_handle
.QueryDisplayInfo3(level
= i
)
143 print 'testing groups'
145 groups
= domain_handle
.EnumDomainGroups()
146 rids
= domain_handle
.LookupNames(groups
)
148 for i
in range(len(groups
)):
149 test_GroupHandle(domain_handle
.OpenGroup(rids
[0][i
]))
153 print 'testing aliases'
155 aliases
= domain_handle
.EnumDomainAliases()
156 rids
= domain_handle
.LookupNames(aliases
)
158 for i
in range(len(aliases
)):
159 test_AliasHandle(domain_handle
.OpenAlias(rids
[0][i
]))
165 # RemoveMemberFromForeignDomain
169 # GetBootKeyInformation()
172 domain_handle
.GetBootKeyInformation()
173 except dcerpc
.NTSTATUS
, arg
:
176 # TestPrivateFunctionsDomain()
179 domain_handle
.TestPrivateFunctionsDomain()
180 except dcerpc
.NTSTATUS
, arg
:
181 if arg
[0] != 0xC0000002L
:
184 def test_ConnectHandle(connect_handle
):
186 print 'testing connect handle'
188 # QuerySecurity/SetSecurity
190 connect_handle
.SetSecurity(connect_handle
.QuerySecurity())
192 # Lookup bogus domain
195 connect_handle
.LookupDomain('xxNODOMAINxx')
196 except dcerpc
.NTSTATUS
, arg
:
197 if arg
[0] != 0xC00000DFL
: # NT_STATUS_NO_SUCH_DOMAIN
202 for domain_name
in connect_handle
.EnumDomains():
204 connect_handle
.GetDomPwInfo(domain_name
)
205 sid
= connect_handle
.LookupDomain(domain_name
)
206 domain_handle
= connect_handle
.OpenDomain(sid
)
208 test_DomainHandle(domain_name
, sid
, domain_handle
)
210 # TODO: Test Shutdown() function
212 def runtests(binding
, creds
):
214 print 'Testing SAMR pipe'
216 pipe
= dcerpc
.pipe_connect(binding
,
217 dcerpc
.DCERPC_SAMR_UUID
, int(dcerpc
.DCERPC_SAMR_VERSION
), creds
)
219 handle
= test_Connect(pipe
)
220 test_ConnectHandle(handle
)