def tearDown(self): super(SamrPasswordTests, self).tearDown() samr.Close(self.user_handle) samr.Close(self.domain_handle) samr.Close(self.handle) samba.tests.delete_force(self.samdb, self.user_dn)
def FillUserInfo(samr, dom_handle, users, level): """fill a user array with user information from samrQueryUserInfo""" for i in range(len(users)): user_handle = samr.OpenUser(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, users[i].idx) info = samr.QueryUserInfo(user_handle, level) info.name = users[i].name info.idx = users[i].idx users[i] = info samr.Close(user_handle)
def test_EnumDomains(samr, handle): """test the samr_EnumDomains interface""" print "Testing samr_EnumDomains" domains = toArray(samr.EnumDomains(handle, 0, -1)) print "Found %d domains" % len(domains) for idx, domain in domains: print "\t%s (%d)" % (display_lsa_string(domain), idx) for idx, domain in domains: print "Testing domain %s" % display_lsa_string(domain) sid = samr.LookupDomain(handle, domain) dom_handle = test_OpenDomain(samr, handle, sid) test_domain_ops(samr, dom_handle) samr.Close(dom_handle)
domains = toArray(samr.EnumDomains(handle, 0, -1)) print "Found %d domains" % len(domains) for idx, domain in domains: print "\t%s (%d)" % (display_lsa_string(domain), idx) for idx, domain in domains: print "Testing domain %s" % display_lsa_string(domain) sid = samr.LookupDomain(handle, domain) dom_handle = test_OpenDomain(samr, handle, sid) test_domain_ops(samr, dom_handle) samr.Close(dom_handle) if len(sys.argv) != 2: print "Usage: samr.js <BINDING>" sys.exit(1) binding = sys.argv[1] print "Connecting to %s" % binding try: samr = samr.samr(binding) except Exception, e: print "Failed to connect to %s: %s" % (binding, e.message) sys.exit(1) handle = test_Connect(samr) test_EnumDomains(samr, handle) samr.Close(handle) print "All OK"