使用R从Windows Cred Vault获取凭据时出错 [英] Error when using R to get credentials from Windows Cred Vault

查看:51
本文介绍了使用R从Windows Cred Vault获取凭据时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误信息...

I receive the following error...

Error in b_wincred_i_get(target) : 
Windows credential store error in 'get': Element not found.

...在R v3.5.1(R Studio v1.1.456)和密钥环v1.1.0中运行以下脚本时.我正在尝试在新的设置上执行此操作,因此不确定是否可以像防火墙问题之类的问题一样简单.尝试获取密码( key_get(json_data $ service,json_data $ user))时,脚本出错.我尝试将服务和用户名手动插入 key_get 方法中(而不是使用配置文件中的变量),但是会遇到相同的错误.配置文件是一个json文件,其中包含除密码以外的所有连接详细信息,密码显然是从Windows Credentials Vault中检索到的.非常感谢为解决此问题而提供的任何帮助.

...when running the following script in R v3.5.1 (R Studio v1.1.456) and keyring v1.1.0. I'm attempting this on a new setup so not sure if this could be as simple as a firewall issue or the like. The script errors out when attempting to get the password (key_get(json_data$service, json_data$user)). I've tried manually plugging in the service and username into the key_get method (instead of using the variables from the config file) but get the same error. The config file is a json file that holds all of the connection details except the password, which obviously gets retrieved from the Windows Credentials Vault. Any help in figuring out a fix for this is greatly appreciated.

library(RJDBC)
library(keyring)
library(jsonlite)

postgres.connection <- function(json_data){

  print("Creating Postgres driver...")
  pDriver <- JDBC(driverClass=json_data$driver, classPath="C:/Users/Drivers/postgresql-42.2.4.jar")

  print("Connecting to Postgres...")
  server <- paste("jdbc:postgresql://", json_data$host, ":", json_data$port, "/", json_data$dbname, sep="")
  pConn <- dbConnect(pDriver, server, json_data$user, key_get(json_data$service, json_data$user))

  return(pConn)

}

json_data <- fromJSON("C:/Users/Configs/Config.json", simplifyVector = TRUE, simplifyDataFrame = TRUE)
json_data_connection <- json_data$postgres$local_read
pc <- postgres.connection(json_data_connection)

推荐答案

您提到这是一个新设置.密码中已经存在密码吗?要进行检查,请转到控制面板">用户帐户">凭据管理器">"Windows凭据",它是否在通用凭据"下?我可以通过运行以下命令得到相同的错误: key_get('not-valid-service','some-user')

You mentioned it's a new setup. Is the password already in credentials? To check, go to 'Control Panel'>'User Accounts'>'Credential Manager'>'Windows Credentials', is it under 'Generic Credentials'? I can get the same error by running: key_get('not-valid-service', 'some-user')

这篇关于使用R从Windows Cred Vault获取凭据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆