Cannot open connection with SQL Server from ISAPI dll RRS feed

  • Question

  • SQL Server 2008 R2 Express

    I have a dll that worked perfectly under Win 7 and IIS 7.5. I am trying to move it to Server 2012 and IIS 8.5. My .net app talks to the SQL Server and so does my dll code (identical connection code and connection string) when run as a standalone app. However, when I run the code as a dll, it works fine until I reach the line that opens the SQL connection. Then it throws an exception but the exception does not provide a string to explain itself (the string is NULL). There is nothing in the Windows event logs for SQL Server, no login failure.

    I presume that the dll is being run by IIS_IUSRS but this is not available to be added as a New Login to SQL Server. Adding IUSR does not help and it has no effective access to my dll app/folder according to IIS.

    Wednesday, January 11, 2017 5:03 PM


  • Somehow I solved the problem. However, I can not tell easily what changed. It just started to work after a reboot.

    Thank you for all your consideration.


    Friday, January 20, 2017 9:36 PM

All replies

  • Right click on your SQL Server, and select properties and then security. Ensure that Login Auditing is enabled for both failed and successful logins.

    Try again from your web server. Wait until failure and then check your SQL Server logs (Management\SQL Server Logs) and see if you can see the connection attempt. You will see the account in use. This should help you to debug this issue. It is a difficult one to figure out.

    • Proposed as answer by Sunit Kapur Tuesday, January 17, 2017 2:16 AM
    Wednesday, January 11, 2017 5:06 PM
  • Hello randallx,

    Have you had the opportunity to try what Hilary suggested?

    http://ekremonsoy.blogspot.com | http://www.ekremonsoy.com | @EkremOnsoy

    Sunday, January 15, 2017 6:24 PM
  • Thank you. I had already enabled auditing for failed logins and the constant probing of external bots is evident. There is no audit entries for my dll's failed open connection attempts.


    Sunday, January 15, 2017 8:33 PM
  • You will need to debug this further.

    Here is how do to this:


    I suspect it the server entry is hardcoded in the dll. Do you have the source for the isapi filter?

    Sunday, January 15, 2017 8:58 PM
  • The dll certainly contains the connection string, which I know is correct. I've tracked the execution and when it reaches the line that calls Open() on the SQL connection it throws an exception. Unfortunately the exception object does not provide any non-NULL description string to help identify the issue. When I run the exact same code as part of a standalone exe, it works flawlessly. There must be some layer of security that disallows the dll running under IIS to talk to the SQL Server.

    I am not sure what you mean by the 'source for the ISAPI filter'? How would I identify the relevant filter and were would the source code be found. I greatly appreciate your assistance. I have put many days into trying to set up this server and overcome every obstacle except this but it is a show-stopper.


    Tuesday, January 17, 2017 1:16 AM
  • By source I mean the code for the ISAPI filter.

    Its been a while since I have worked with them, but when they make a database call they either use a sql authentication account, a windows account - using pass through, or some form of impersonation.

    If it is using impersonation it might use the IUSER account, an authenticated account, a specific user account.

    Did you check the SQL Server logs and audit failed users to see what account is trying to make a connection to SQL Server?

    You should also be able to audit failed logins hitting your windows machine - these will show up in the security log in event viewer.

    Just out of curiosity - how are you so sure you know the connection string inside the isapi filter?

    Here is how to configure your SQL Server to see failed logins.

    Tuesday, January 17, 2017 1:31 AM
  • Somehow I solved the problem. However, I can not tell easily what changed. It just started to work after a reboot.

    Thank you for all your consideration.


    Friday, January 20, 2017 9:36 PM