简体   繁体   English

IIS7的MSSQL连接

[英]MSSQL Connection from IIS7

VS is a pain in the ass. VS是个麻烦。

When debugging with IIS Express - without creating SSL certificates or anything - everything works fine: DB connection, AD connection, SQL connection. 使用IIS Express调试时-不创建SSL证书或其他任何东西-一切正常:数据库连接,AD连接,SQL连接。 When sending everything on IIS 7 with self-signed certificate, nothing works, everything throws errors, and I am left alone without VS debugging tools. 当使用自签名证书在IIS 7上发送所有内容时,没有任何效果,所有内容都会引发错误,并且我没有VS调试工具就任其孤独。

How come the following code 下面的代码怎么来

        dbconn = new SqlConnection("user id=test;password=test;server=server01;Trusted_Connection=true;TrustServerCertificate=true;database=test;connection timeout=5");
        try
        {
            dbconn.Open();
        }
        catch (Exception e)
        {
            Debug.Message("dbconn.open failed: " + e.Message);
        }

works when run on my dev machines, but on IIS7 on server03 it returns 在我的开发机上运行时可以运行,但是在server03上的IIS7上它可以返回

dbconn.open failed: Login failed for user 'INTRA\SERVER03$'.

Especially why is the user 'INTRA\\SERVER03$' (which does not exist, btw), and not the user I explicitly specified in the connection string? 尤其是为什么用户“ INTRA \\ SERVER03 $”(不存在,顺便说一句)而不是我在连接字符串中明确指定的用户?

The problem was the connection string, that should be set to: 问题是连接字符串,应将其设置为:

user id=test;password=test;server=server01;TrustServerCertificate=true;database=test;connection timeout=5

After this is done, the next problem may be that "the SELECT permission was denied", which was the case because my sql user "test" was not set to db_datareader for database "test" (in SSMS under Security => Logins). 完成此操作后,下一个问题可能是“ SELECT权限被拒绝”,之所以如此,是因为我的sql用户“ test”未设置为数据库“ test”的db_datareader(在SSMS中,在Security => Logins下)。

This gives me a nice follow-up question: Why the heck did it work at all in IIS Express? 这给了我一个很好的后续问题: 为什么它在IIS Express中根本无法工作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM