static bool wbinfo_lookupsid_fullname(const char *sid_str) { wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; struct wbcDomainSid sid; char *domain; char *name; enum wbcSidType type; /* Send off request */ wbc_status = wbcStringToSid(sid_str, &sid); if (!WBC_ERROR_IS_OK(wbc_status)) { return false; } wbc_status = wbcGetDisplayName(&sid, &domain, &name, &type); if (!WBC_ERROR_IS_OK(wbc_status)) { return false; } /* Display response */ d_printf("%s%c%s %d\n", domain, winbind_separator(), name, type); return true; }
static bool test_wbc_users(struct torture_context *tctx) { const char *domain_name = NULL; uint32_t num_users; const char **users; int i; struct wbcInterfaceDetails *details; torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details), "%s", "wbcInterfaceDetails failed"); domain_name = talloc_strdup(tctx, details->netbios_domain); wbcFreeMemory(details); torture_assert_wbc_ok(tctx, wbcListUsers(domain_name, &num_users, &users), "%s", "wbcListUsers failed"); torture_assert(tctx, !(num_users > 0 && !users), "wbcListUsers returned invalid results"); for (i=0; i < MIN(num_users,100); i++) { struct wbcDomainSid sid, *sids; enum wbcSidType name_type; char *domain; char *name; char *sid_string; uint32_t num_sids; torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, users[i], &sid, &name_type), "wbcLookupName of %s failed", users[i]); torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER, "wbcLookupName expected WBC_SID_NAME_USER"); wbcSidToString(&sid, &sid_string); torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type), "wbcLookupSid of %s failed", sid_string); torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER, "wbcLookupSid of expected WBC_SID_NAME_USER"); torture_assert(tctx, name, "wbcLookupSid returned no name"); wbcFreeMemory(domain); wbcFreeMemory(name); torture_assert_wbc_ok(tctx, wbcLookupUserSids(&sid, true, &num_sids, &sids), "wbcLookupUserSids of %s failed", sid_string); torture_assert_wbc_ok( tctx, wbcGetDisplayName(&sid, &domain, &name, &name_type), "wbcGetDisplayName of %s failed", sid_string); wbcFreeMemory(domain); wbcFreeMemory(name); wbcFreeMemory(sids); wbcFreeMemory(sid_string); } wbcFreeMemory(users); return true; }