使用Windows安全性和模拟的远程连接到SQL Server
我想调整Windows登录到DBMail(用于发送附件),第一步是简单的打开连接到存储DBMail配置的SQL Server。
我已经在名为dbmail
的Windows中创建了一个帐户,然后为其创建了一个SQL登录:
CREATE LOGIN [QQQQQQQ\dbmail] FROM WINDOWS
我将此SQL登录所需的许可设置为(SQLADMINISTRATOR)
。
然后,我尝试使用此连接字符串连接到SQL:
ATT_tds_STRING = "Data Source=localhost; Database=YYYYY; uid=QQQQQQQQ\dbmail; pwd=xxxxxxxxxxxx; Integrated Security=SSPI;"
我放置在com-object中的功能
Public Function DbMailSendMail(CN As String, DbMailProfileName As String, SmSender As String, SmRecptLst As String, SmCCLst As String, SmBCCLst As String, SmSubject As String, SmMsg As String, SmAttach As String) As String Implements IDbMail.DbMailSendMail
Dim SQLCN As New SqlClient.SqlConnection(CN)
SQLCN.Open()
Try
Dim CMD As New SqlClient.SqlCommand($"EXEC msdb.dbo.sp_send_dbmail @body_format = 'HTML', " &
....
不幸的是,当我从ASP页面调用我的功能时,
Dim Mailer1, Res1
Set Mailer1 = Server.CreateObject("TDS.DbMail")
Res1 = Mailer1.DbMailSendMail (ATT_tds_STRING, "ZZZZZZZ", "", Request.Form("Mailto"), "", "", Request.Form("title"), Request.Form("body"), "C:\www\tdsv5\Images\BeOS_Help.gif")
我会得到一个奇怪的结果
.NET SQLCLCLIENT数据提供商错误'80131904'
用户“ NT权限\ iusr”登录失败。
我希望Windows身份验证在sqlclient.sqlconnection(cn)
带有登录QQQQQQQQ \ dbmail(因为我使用恰好使用Windows登录和SSPI安全性),但是Windows似乎正在使用IIS Incerseration nt promentation nt wertional ancement nt wertion connect connect connect到SQL Server。
I want to tune Windows login to dbmail (for sending attachment), first step is simple open connection to SQL Server where the dbmail configuration is stored.
I have created an account in Windows named dbmail
, and then I created a SQL login for it:
CREATE LOGIN [QQQQQQQ\dbmail] FROM WINDOWS
I set needed permission for this SQL login to (SqlAdministrator)
.
Then I try to connect to SQL with this connection string:
ATT_tds_STRING = "Data Source=localhost; Database=YYYYY; uid=QQQQQQQQ\dbmail; pwd=xxxxxxxxxxxx; Integrated Security=SSPI;"
My function placed inside COM-object
Public Function DbMailSendMail(CN As String, DbMailProfileName As String, SmSender As String, SmRecptLst As String, SmCCLst As String, SmBCCLst As String, SmSubject As String, SmMsg As String, SmAttach As String) As String Implements IDbMail.DbMailSendMail
Dim SQLCN As New SqlClient.SqlConnection(CN)
SQLCN.Open()
Try
Dim CMD As New SqlClient.SqlCommand(quot;EXEC msdb.dbo.sp_send_dbmail @body_format = 'HTML', " &
....
When I call my function from ASP page
Dim Mailer1, Res1
Set Mailer1 = Server.CreateObject("TDS.DbMail")
Res1 = Mailer1.DbMailSendMail (ATT_tds_STRING, "ZZZZZZZ", "", Request.Form("Mailto"), "", "", Request.Form("title"), Request.Form("body"), "C:\www\tdsv5\Images\BeOS_Help.gif")
Unfortunately I get a strange result
.Net SqlClient Data Provider error '80131904'
Login failed for user 'NT AUTHORITY\IUSR'.
I expect Windows authentication in SqlClient.SqlConnection(CN)
with login QQQQQQQ\dbmail (because I use exactly Windows login and SSPI security), however Windows appears to be using IIS impersonation account NT AUTHORITY\IUSR to connect to SQL Server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据@Charlieface的建议,我已经创建了登录名
,并设置为MSDB
之后,一切正常。连接字符串是
According advice @Charlieface, I have created login
and set up to this login special roles in MSDB
DatabasemailUserRole
After that all working fine. Connection string is