Exemplo n.º 1
0
static bool wbinfo_auth(char *username, const char *pass)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;

	wbc_status = wbcAuthenticateUser(username, pass);

	d_printf("plaintext password authentication %s\n",
		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");

#if 0
	if (response.data.auth.nt_status)
		d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", 
			 response.data.auth.nt_status_string,
			 response.data.auth.nt_status,
			 response.data.auth.error_string);
#endif

	return WBC_ERROR_IS_OK(wbc_status);
}
Exemplo n.º 2
0
static bool test_wbc_authenticate_user_int(struct torture_context *tctx,
        const char *correct_password)
{
    struct wbcAuthUserParams params;
    struct wbcAuthUserInfo *info = NULL;
    struct wbcAuthErrorInfo *error = NULL;
    wbcErr ret;

    ret = wbcAuthenticateUser(cli_credentials_get_username(cmdline_credentials), correct_password);
    torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
                             "wbcAuthenticateUser of %s failed",
                             cli_credentials_get_username(cmdline_credentials));

    ZERO_STRUCT(params);
    params.account_name		= cli_credentials_get_username(cmdline_credentials);
    params.level			= WBC_AUTH_USER_LEVEL_PLAIN;
    params.password.plaintext	= correct_password;

    ret = wbcAuthenticateUserEx(&params, &info, &error);
    torture_assert_wbc_equal(tctx, ret, WBC_ERR_SUCCESS,
                             "wbcAuthenticateUserEx of %s failed", params.account_name);
    wbcFreeMemory(info);
    info = NULL;

    wbcFreeMemory(error);
    error = NULL;

    params.password.plaintext       = "wrong";
    ret = wbcAuthenticateUserEx(&params, &info, &error);
    torture_assert_wbc_equal(tctx, ret, WBC_ERR_AUTH_ERROR,
                             "wbcAuthenticateUserEx for %s succeeded where it "
                             "should have failed", params.account_name);
    wbcFreeMemory(info);
    info = NULL;

    wbcFreeMemory(error);
    error = NULL;

    return true;
}
Exemplo n.º 3
0
static bool wbinfo_auth(char *username)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	char *s = NULL;
	char *p = NULL;
	char *password = NULL;
	char *name = NULL;

	if ((s = SMB_STRDUP(username)) == NULL) {
		return false;
	}

	if ((p = strchr(s, '%')) != NULL) {
		*p = 0;
		p++;
		password = SMB_STRDUP(p);
	} else {
		password = wbinfo_prompt_pass(NULL, username);
	}

	name = s;

	wbc_status = wbcAuthenticateUser(name, password);

	d_printf("plaintext password authentication %s\n",
		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");

#if 0
	if (response.data.auth.nt_status)
		d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
			 response.data.auth.nt_status_string,
			 response.data.auth.nt_status,
			 response.data.auth.error_string);
#endif

	SAFE_FREE(s);
	SAFE_FREE(password);

	return WBC_ERROR_IS_OK(wbc_status);
}