使用连接字符串中的 AD 用户名和密码对 SQL 进行 Windows 身份验证

发布于 2024-09-11 12:21:15 字数 314 浏览 1 评论 0原文

您好,我正在编写一个 ASP.Net MVC Intranet 应用程序,可以通过手持设备和一系列浏览器访问该应用程序。我的用户都有 AD 帐户,并且根据他们所在的区域对我们的 SQL 数据库视图/过程拥有不同的权限。数据库还使用 CURRENT_USER 进行水平分区。

由于需要访问应用程序的设备范围很大,我不能依赖模拟/委托或受信任的子系统。我希望用户在上述机制失败时只需输入用户名和密码(与 AD 相同)。

有谁知道如何在连接字符串中使用 AD 用户名和密码来访问数据库,而无需创建一组 SQL 镜像帐户?我无法使用网络服务或 sql 代理帐户登录,因为数据库需要用户感知。

Hi I'm writing an ASP.Net MVC intranet application which is accessed via handhelds and a range of browsers. My users all have AD accounts and have different permission to our SQL database views/procs depending on who they area. The database also uses CURRENT_USER for horizontal partitioning.

Because of the range of devices that need to access the application I can't rely on impersonation/delegation or the trusted subsystem. I want the user to simply input username and password (same as AD) when the above mechanisms fail.

Does anyone know how I can use AD username and password in a connection string to access the database without creating a set of SQL mirror accounts? I can't login with network service or a sql proxy account because the database needs to be user aware.

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

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

发布评论

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

评论(1

一笑百媚生 2024-09-18 12:21:15

您不能在连接字符串中执行此操作。

最好的办法是让 ASP.NET 代码模拟您想要连接的用户。
对于 ASP.NET,这可能有点棘手,因为已经存在模拟层,但这是可行的。

请参阅MSKB 文章中名为“在代码中模拟特定用户” 让您开始走上正确的道路。

You can't do it in the connection string.

Your best bet is to make your ASP.NET code impersonate the user you want to connect as.
This can be a little tricky with ASP.NET as there is already an impersonation layer going on, but it is doable.

See the section of this MSKB article called "Impersonate a Specific User in Code" to get you started down the right path.

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