RavenDB 网络访问 [英] RavenDB Network Access

查看:54
本文介绍了RavenDB 网络访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难找到有关如何让 RavenDB 在网络上工作的信息.在同一个网络中,我可以运行我的应用程序实例,它会显示来自我的 RavenDB 的数据.但是,当我尝试写入数据时,出现 401 Unauthorized 异常.

I'm having a difficult time finding information on how to get RavenDB to work on a network. Within the same network, I can have an instance of my app running, and it will show data from my RavenDB. However, when I try to write data, I get a 401 Unauthorized exception.

设置要通过网络访问的 RavenDB 的正确方法是什么?

What is the correct way to set up a RavenDB to be accessed over the network?

现在,我在 Raven.Server.exe.config 中有这个,这只是一个短期解决方案:

Right now, I have this in Raven.Server.exe.config, which is just a short-term solution:

<add key="Raven/AnonymousAccess" value="All" />

我不明白的是,RavenDB 网站说要使用这样的东西:

What I don't understand, is that the RavenDB web site says to use something like this:

<connectionStrings>
  <add name="RavenDb" 
       connectionString="Url=http://serverName:8080;user=user;password=password"/>
</connectionStrings>

好的,这对于正在运行的应用程序来说很棒,但是我如何设置 RavenDB 服务器以允许该用户和密码?这只是错误的方法吗(以某种方式设置 RavenDB 配置文件以允许这些凭据)?如果这是错误的,我应该如何在服务器端定义凭据?

Ok, that's great for the application that's running, but how do I set the RavenDB server to allow that user and password? Is that just the wrong way to do it (somehow setting the RavenDB config file to allow those credentials)? If that's wrong, how am I supposed to define credentials on the server side?

这是我的尝试和结果:

我通过双击 Raven.Server.exe 运行 RavenDB.

I'm running RavenDB by double-clicking Raven.Server.exe.

场景一

客户端应用程序配置:

  <connectionStrings>
    <add name="RavenDb" connectionString="Url = http://server:8080;domain=Xx;user=Xx\user;password=pw"/>
  </connectionStrings>

文档存储设置:

DocumentStore documentStore = new DocumentStore();
documentStore.ConnectionStringName = "RavenDb";
documentStore.Initialize();

保存操作:

Session.Store(objectToSave);

结果:远程服务器返回错误:(401) 未经授权."

Result: "The remote server returned an error: (401) Unauthorized."

场景 2

客户端 app.config:

Client app.config:

<add key="databaseUrl" value="http://server:8080"/>

文档存储设置:

string databaseUrl = ConfigurationManager.AppSettings["databaseUrl"];            
DocumentStore documentStore = new DocumentStore();
documentStore.Url = databaseUrl;
documentStore.Initialize();

保存操作:

Session.Store(objectToSave);

结果:远程服务器返回错误:(401) 未经授权."内部异常:目标主体名称不正确"

Result: "The remote server returned an error: (401) Unauthorized." Inner exception: "The target principal name is incorrect"

推荐答案

在运行 RavenDB 的机器上创建一个本地用户并使用您想要的任何凭据.然后为该用户分配/Data 目录(以及/Tenants 目录,如果需要)的读/写权限.

Create a local user on the machine RavenDB runs on and use any credentials you'd like. Then assign read/write permissions for the /Data directory (and the /Tenants directory if needed) to this user.

如果您将 RavenDB 作为服务或独立应用程序运行,则远程身份验证应使用 (windows) 用户凭据.如果您在 IIS 上运行,请确保您启用了 Windows 身份验证(默认情况下禁用!).

If you're running RavenDB as a service or standalone application, remote auth should work with the (windows)users credentials. If you're running on IIS, please make sure you have Windows Authentication enabled (disabled by default!).

这篇关于RavenDB 网络访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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