将 Forms Auth 用户凭据传递到 SQL Server 数据库连接
我的网络应用程序使用 .NET 3.5 框架、VS 2008 和 SQL Server 数据库。我正在使用表单身份验证和通用登录来验证用户对 aspx 页面的访问。有没有办法可以将用户的表单身份验证凭据(不同于他们的 Windows 登录名)传递到 sql server 连接字符串,以便他们的数据库权限可以基于该登录名?
My web app is using .NET 3.5 framework, VS 2008 with a SQL Server database. I am using Forms authentication and the generic login to validate user access to the aspx pages. Is there a way I can pass the user's form auth credentials (different from their Windows login) to the sql server connectionstring so that their database permissions can be based on that login?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以构建一个连接字符串,插入表单身份验证用户名和密码(您必须将其保存在某处)。这只是简单的字符串操作 - 有一个带有用户名和密码占位符的连接字符串。
一个缺点是您无法在不同用户之间共享池连接,因此无法从连接池中受益。
在一个拥有多个用户的网站上,这很快就会成为一个问题。
You could construct a connection string, inserting the Forms Authentication username and password (that you'll have to have saved somewhere). It's just simple string manipulation - have a connection string with placeholders for the username and password.
One disadvantage is that you won't be able to share pooled connections between different users, so won't benefit from connection pooling.
On a site with more than a handful of users this will quickly become a problem.