Пример #1
0
static bool print_domain_users(const char *domain)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	uint32_t i;
	uint32_t num_users = 0;
	const char **users = NULL;

	/* Send request to winbind daemon */

	/* '.' is the special sign for our own domain */
	if (domain && strcmp(domain, ".") == 0) {
		domain = get_winbind_domain();
	}

	wbc_status = wbcListUsers(domain, &num_users, &users);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	for (i=0; i < num_users; i++) {
		d_printf("%s\n", users[i]);
	}

	wbcFreeMemory(users);

	return true;
}
Пример #2
0
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;
}