如何使用 .NET 与多个用户一起访问 Oracle 中自己的数据库?

发布于 2024-10-15 02:20:10 字数 415 浏览 3 评论 0原文

我和我的 2 个朋友完成了基于 .NET 和 Oracle 的大学应用程序的开发,但有一个小问题。我们现在才注意到它,我们修复它并不真正相关,但无论如何我们都想修复它。

问题是,大学提供了一个 Oracle 服务器,每个学生都有一个拥有自己数据库的帐户。由于我们属于同一开发团队,因此我们决定使用相同的密码以进行简化。我们只需要更改用户名即可在我们自己的数据库上工作,每个人都可以调试他正在处理的任何内容,而不会弄乱其他数据库。

我们认为这只是更改连接字符串中的用户名的问题。问题是我们正在使用数据集,而且它们似乎还存储连接字符串,这对我们根本没有帮助。

难道没有一种方法可以简单地将一个连接与一个用户名/密码对存储在一个地方并完成吗?

不知道是否相关,但我们正在使用 Oracle Developer Tools for Visual Studio。

My and 2 of my friends finished working on a .NET and Oracle based application for university but there's a little problem. We only noticed about it now and it's not really relevant that we fix it but we would like to anyway.

The thing is, the university provides an Oracle server and each student has an account with it's own database. Since we were on the same developing team we decided to use the same password for simplification. We would only need to change the username to work on our own database and each one could debug whatever he was working on without messing up the others database.

We thought this was just a matter of changing the username in the connection string. The problem is that we are using DataSets and it seems these also store the connection string which doesn't help us at all.

Isn't there a way to simply have ONE connection with ONE username/password pair store in a SINGLE place and be done with it?

Dunno if it's relevant but we are using the Oracle Developer Tools for Visual Studio.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧城空念 2024-10-22 02:20:10

根据您的评论,您似乎正在寻找“代理用户”。因此,您的 Web 应用程序以用户 webapp 身份使用一些密码连接到数据库。就其本身而言,它没有任何关系。然后,Web 用户 flynn 出现并想要使用您的 Web 应用程序。问题是,数据位于 flynn 的架构中。会发生的情况是,webapp 说“嘿,我要成为 flynn 一段时间”,而数据库则说“是的,我认识你,你可以< code>flynn 一会儿。”从那时起,webapp 就可以(默认)在 flynn 的架构中工作。

有关代理身份验证的更多信息,请参阅 ODP 文档

Based off your comment it looks like you're looking for "Proxy Users". So, your web application connects to the database as user webapp with some password. By itself, it doesn't have anything to do. The, the web user flynn comes along and wants to use your web application. The thing is, the data is in flynn's schema. What would happen is that webapp says "Hey, I'm going to be flynn for a while" and the database says "Yeah, I know you, you can be flynn for a bit." And from then on webapp works (by default) in flynn's schema.

More information about proxy authentication is available in the ODP documentation.

停顿的约定 2024-10-22 02:20:10

编辑:这不是提问者所说的。抱歉!

恭喜!您在学校遇到了“现实世界”的编码问题。伙计,我希望这种情况在我上大学时更频繁地发生在我身上。

您有几个选项:

  1. 选择要使用的一个用户的架构。也就是说,每个开发人员都将使用自己的用户名/密码登录。但是,一旦他们登录,他们将使用以下命令设置会话的默认架构:ALTER SESSION SET CURRENT_SCHEMA = SCHEMA_NAME_HERE 这样,当您引用表T时,它就没有架构名称摆在所有开发人员面前。诀窍是在同时处理项目时不要破坏彼此的更改。协调是必要的。根据人数,这可能是可行的。

  2. 使用外部源代码控制工具来同步更改。这包括 Subversion (SVN)、Git、Mercurial 等。一旦进入工作场所,您将需要使用其中的某种形式,因此现在了解这些东西可能会很有用。

Edit: This is not what the asker was talking about. Sorry!

Congratulations! You've met a "real world" coding issue in school. Man, I wish this happened to me more often while attending University.

You've got a couple options:

  1. Pick one user's schema to work with. That is, every developer will login with their own username/password. However, once they login they will set their session's default schema using this command: ALTER SESSION SET CURRENT_SCHEMA = SCHEMA_NAME_HERE That way when you refer to table T it is without the schema name in front for all developers. The trick is to not clobber each other's changes when working simultaneously on the project. Coordination will be necessary. Depending upon the number of people this may be feasible.

  2. Use an outside source control tool to synchronize changes. This includes things like Subversion (SVN), Git, Mercurial, etc. You will need to use some form of this once you get into the workplace, so it might be useful to learn about this stuff now.

↙厌世 2024-10-22 02:20:10

在哪里存储连接字符串?
在 web.config 或 app.config 中
使用 ConfigurationManager 或 WebConfigurationManager 检索

来自 web.config 的示例

<connectionStrings>
    <add name="DB:PM" connectionString="Persist Security Info=False;User Id=**UserName**;Password=**PASSWORD**;Data Source=**DataBaseName**" providerName="Oracle.DataAccess.Client"/>
</connectionStrings>

检索示例

m_strConnectionsString = WebConfigurationManager.ConnectionStrings["DB:PM"].ConnectionString;

1)
我猜测,但我认为你们每个人都有自己的模式,而不是数据库。
这些模式可能都存在于同一个数据库中。
架构名称和用户名通常是相同的。

您看到表名称前面的是架构名称。这通常称为完全限定名称。 Fred 可以有一个名为女朋友的表,Tom 可以有一个名为女朋友的表。
Fred.girlfriends 表与 Tom.girlfriends 表不是同一个表。

2)
创建一个或多个数据库角色(角色是数据库对象,而不是架构对象)
使用完全限定名称为所需的表授予角色权限。

将角色授予用户(您和您的朋友)
现在,你们每个人都有权选择(并可能修改)表中的数据。
您仍然需要使用完全限定名称从表中选择数据。如果您不使用完全限定名称,那么当您从女朋友中进行选择时,您将获得属于您自己的架构的数据,这可能是您想要的,但您最好使用完全限定名称。如果其他人使用您的应用程序,并且您使用完全限定名称,他们仍然会获得正确的数据。

希望我没有完全错过这里的重点,我希望你无论如何都可以使用这些信息
哈夫·萨瑟

Where to store connection strings?
Either in web.config or app.config
Retrieve using ConfigurationManager or WebConfigurationManager

Example from a web.config

<connectionStrings>
    <add name="DB:PM" connectionString="Persist Security Info=False;User Id=**UserName**;Password=**PASSWORD**;Data Source=**DataBaseName**" providerName="Oracle.DataAccess.Client"/>
</connectionStrings>

Example of retrieval

m_strConnectionsString = WebConfigurationManager.ConnectionStrings["DB:PM"].ConnectionString;

1)
I am guessing, but I think you each have your own schema, not database.
The schemas probably all exist in the same database.
Schema names and usernames are usually the same.

What you are seeing that preceeds the table name is the schema name. This is often referred to as a fully qualified name. Fred can have a table named girlfriends, Tom can have a table named girlfriends.
The table Fred.girlfriends is not the same table as the table Tom.girlfriends.

2)
create one or more database roles (roles are database objects, not schema objects)
give the role permissions to the tables you want, using fully qualified names.

Grant the roles to the users (you and your friends)
Now you each have rights to select (and possibly modify) data in the tables.
You will still have to select the data from tables using fully qualified names. If you do not use fully qualified names, when you select from girlfriends, you will get the data that is your own schema, which might be what you want, but you are always better to use fully qualified names. If someone else uses your application, they will still get the correct data if you use fully qualified names.

Hope I haven't completely missed the mark here, and I hope you can use this information anyway
Harv Sather

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文