Beispiel #1
0
static bool test_wbc_pingdc(struct torture_context *tctx)
{
    struct wbcInterfaceDetails *details;

    torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_DOMAIN_NOT_FOUND,
                             "%s", "wbcPingDc failed");
    torture_assert_wbc_ok(tctx, wbcPingDc(NULL, NULL),
                          "%s", "wbcPingDc failed");

    torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
                          "%s", "wbcInterfaceDetails failed");
    torture_assert(tctx, details,
                   "wbcInterfaceDetails returned NULL pointer");
    torture_assert(tctx, details->netbios_domain,
                   "wbcInterfaceDetails returned NULL netbios_domain");

    torture_assert_wbc_ok(tctx, wbcPingDc(details->netbios_domain, NULL),
                          "wbcPingDc(%s) failed", details->netbios_domain);

    torture_assert_wbc_ok(tctx, wbcPingDc("BUILTIN", NULL),
                          "%s", "wbcPingDc(BUILTIN) failed");

    wbcFreeMemory(details);
    return true;
}
Beispiel #2
0
static bool test_wbc_get_sidaliases(struct torture_context *tctx)
{
	struct wbcDomainSid builtin;
	struct wbcDomainInfo *info;
	struct wbcInterfaceDetails *details;
	struct wbcDomainSid sids[2];
	uint32_t *rids;
	uint32_t num_rids;
	wbcErr ret;

	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
		"wbcInterfaceDetails failed");
	torture_assert_wbc_ok(
		tctx, wbcDomainInfo(details->netbios_domain, &info),
		"wbcDomainInfo failed");
	wbcFreeMemory(details);

	sids[0] = info->sid;
	sids[0].sub_auths[sids[0].num_auths++] = 500;
	sids[1] = info->sid;
	sids[1].sub_auths[sids[1].num_auths++] = 512;
	wbcFreeMemory(info);

	torture_assert_wbc_ok(
		tctx, wbcStringToSid("S-1-5-32", &builtin),
		"wbcStringToSid failed");

	ret = wbcGetSidAliases(&builtin, sids, 2, &rids, &num_rids);
	torture_assert_wbc_ok(tctx, ret, "wbcGetSidAliases failed");

	wbcFreeMemory(rids);

	return true;
}
Beispiel #3
0
static bool test_wbc_ping(struct torture_context *tctx)
{
	torture_assert_wbc_ok(tctx, wbcPing(),
		"wbcPing failed");

	return true;
}
Beispiel #4
0
static bool test_wbc_lookup_rids(struct torture_context *tctx)
{
	struct wbcDomainSid builtin;
	uint32_t rids[2] = { 544, 545 };
	const char *domain_name, **names;
	enum wbcSidType *types;
	wbcErr ret;

	wbcStringToSid("S-1-5-32", &builtin);

	ret = wbcLookupRids(&builtin, 2, rids, &domain_name, &names,
			    &types);
	torture_assert_wbc_ok(tctx, ret, "wbcLookupRids failed");

	torture_assert_str_equal(
		tctx, names[0], "Administrators",
		"S-1-5-32-544 not mapped to 'Administrators'");
	torture_assert_str_equal(
		tctx, names[1], "Users", "S-1-5-32-545 not mapped to 'Users'");

	wbcFreeMemory(discard_const_p(char ,domain_name));
	wbcFreeMemory(names);
	wbcFreeMemory(types);

	return true;
}
Beispiel #5
0
static bool test_wbc_guidtostring(struct torture_context *tctx)
{
	struct wbcGuid guid;
	const char *guid_string = "f7cf07b4-1487-45c7-824d-8b18cc580811";
	char *guid_string2;

	torture_assert_wbc_ok(tctx, wbcStringToGuid(guid_string, &guid),
		"wbcStringToGuid failed");
	torture_assert_wbc_ok(tctx, wbcGuidToString(&guid, &guid_string2),
		"wbcGuidToString failed");
	torture_assert_str_equal(tctx, guid_string, guid_string2,
		"guid strings differ");
	wbcFreeMemory(guid_string2);

	return true;
}
Beispiel #6
0
static bool test_wbc_sidtostring(struct torture_context *tctx)
{
	struct wbcDomainSid sid;
	const char *sid_string = "S-1-5-32";
	char *sid_string2;

	torture_assert_wbc_ok(tctx, wbcStringToSid(sid_string, &sid),
		"wbcStringToSid failed");
	torture_assert_wbc_ok(tctx, wbcSidToString(&sid, &sid_string2),
		"wbcSidToString failed");
	torture_assert_str_equal(tctx, sid_string, sid_string2,
		"sid strings differ");
	wbcFreeMemory(sid_string2);

	return true;
}
Beispiel #7
0
static bool test_wbc_resolve_winsbyip(struct torture_context *tctx)
{
    const char *ip;
    const char *host;
    struct nbt_name nbt_name;
    char *name;
    wbcErr ret;
    NTSTATUS status;

    host = torture_setting_string(tctx, "host", NULL);

    torture_comment(tctx, "test-WinsByIp: host='%s'\n", host);

    make_nbt_name_server(&nbt_name, host);

    status = resolve_name_ex(lpcfg_resolve_context(tctx->lp_ctx),
                             0, 0, &nbt_name, tctx, &ip, tctx->ev);
    torture_assert_ntstatus_ok(tctx, status,
                               talloc_asprintf(tctx,"Failed to resolve %s: %s",
                                       nbt_name.name, nt_errstr(status)));

    torture_comment(tctx, "test-WinsByIp: ip='%s'\n", ip);

    ret = wbcResolveWinsByIP(ip, &name);

    torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP for %s failed", ip);

    wbcFreeMemory(name);

    return true;
}
Beispiel #8
0
static bool test_wbc_pingdc(struct torture_context *tctx)
{
	torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_NOT_IMPLEMENTED,
		"wbcPingDc failed");
	torture_assert_wbc_ok(tctx, wbcPingDc(NULL, NULL),
		"wbcPingDc failed");

	return true;
}
Beispiel #9
0
static bool test_wbc_lookupdcex(struct torture_context *tctx)
{
	const char *domain_name = NULL;
	struct wbcInterfaceDetails *details;
	struct wbcDomainControllerInfoEx *dc_info;

	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
		"wbcInterfaceDetails failed");

	domain_name = talloc_strdup(tctx, details->netbios_domain);
	wbcFreeMemory(details);

	torture_assert_wbc_ok(tctx, wbcLookupDomainControllerEx(domain_name, NULL, NULL, 0, &dc_info),
		"wbcLookupDomainControllerEx failed");
	wbcFreeMemory(dc_info);

	return true;
}
Beispiel #10
0
static bool test_wbc_domain_info(struct torture_context *tctx)
{
	struct wbcDomainInfo *info;
	struct wbcInterfaceDetails *details;

	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
		"wbcInterfaceDetails failed");
	torture_assert_wbc_ok(
		tctx, wbcDomainInfo(details->netbios_domain, &info),
		"wbcDomainInfo failed");
	wbcFreeMemory(details);

	torture_assert(tctx, info,
		"wbcDomainInfo returned NULL pointer");
	wbcFreeMemory(info);

	return true;
}
Beispiel #11
0
static bool test_wbc_groups(struct torture_context *tctx)
{
    const char *domain_name = NULL;
    uint32_t num_groups;
    const char **groups;
    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, wbcListGroups(domain_name, &num_groups, &groups),
                          "wbcListGroups in %s failed", domain_name);
    torture_assert(tctx, !(num_groups > 0 && !groups),
                   "wbcListGroups returned invalid results");

    for (i=0; i < MIN(num_groups,100); i++) {

        struct wbcDomainSid sid;
        enum wbcSidType name_type;
        char *domain;
        char *name;
        char *sid_string;

        torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, groups[i], &sid, &name_type),
                              "wbcLookupName for %s failed", domain_name);
        wbcSidToString(&sid, &sid_string);
        torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
                              "wbcLookupSid of %s failed", sid_string);
        wbcFreeMemory(sid_string);
        torture_assert(tctx, name,
                       "wbcLookupSid returned no name");
    }
    wbcFreeMemory(groups);

    return true;
}
Beispiel #12
0
static bool test_wbc_interface_details(struct torture_context *tctx)
{
	struct wbcInterfaceDetails *details;

	torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
		"wbcInterfaceDetails failed");
	torture_assert(tctx, details,
		"wbcInterfaceDetails returned NULL pointer");

	wbcFreeMemory(details);

	return true;
}
Beispiel #13
0
static bool test_wbc_trusts(struct torture_context *tctx)
{
	struct wbcDomainInfo *domains;
	size_t num_domains;
	int i;

	torture_assert_wbc_ok(tctx, wbcListTrusts(&domains, &num_domains),
		"wbcListTrusts failed");
	torture_assert(tctx, !(num_domains > 0 && !domains),
		"wbcListTrusts returned invalid results");

	for (i=0; i < MIN(num_domains,100); i++) {

		struct wbcAuthErrorInfo *error;
		/*
		struct wbcDomainSid sid;
		enum wbcSidType name_type;
		char *domain;
		char *name;
		*/
		torture_assert_wbc_ok(tctx, wbcCheckTrustCredentials(domains[i].short_name, &error),
			"wbcCheckTrustCredentials failed");
		/*
		torture_assert_wbc_ok(tctx, wbcLookupName(domains[i].short_name, NULL, &sid, &name_type),
			"wbcLookupName failed");
		torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_DOMAIN,
			"wbcLookupName expected WBC_SID_NAME_DOMAIN");
		torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
			"wbcLookupSid failed");
		torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_DOMAIN,
			"wbcLookupSid expected WBC_SID_NAME_DOMAIN");
		torture_assert(tctx, name,
			"wbcLookupSid returned no name");
		*/
	}
	wbcFreeMemory(domains);

	return true;
}
Beispiel #14
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;
}
Beispiel #15
0
static bool test_wbc_resolve_winsbyip(struct torture_context *tctx)
{
	const char *ip;
	char *name;
	wbcErr ret;

	ip = torture_setting_string(tctx, "host", NULL);

	ret = wbcResolveWinsByIP(ip, &name);

	torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP failed");

	wbcFreeMemory(name);

	return true;
}
Beispiel #16
0
static bool test_wbc_resolve_winsbyname(struct torture_context *tctx)
{
	const char *name;
	char *ip;
	wbcErr ret;

	name = torture_setting_string(tctx, "host", NULL);

	ret = wbcResolveWinsByName(name, &ip);

	if (is_ipaddress(name)) {
		torture_assert_wbc_equal(tctx, ret, WBC_ERR_DOMAIN_NOT_FOUND, "wbcResolveWinsByName failed");
	} else {
		torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName failed");
	}

	return true;
}