Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitemap Security Trimming throws SQL error

I am using the default Sitemap provider with secutiry trimming. But, some how, I get:

A network-related or instance-specific error occurred while establishing a connection to SQL Server.

I'm thinking the sitemap provider is looking for the roles in the wrong place. My configuration is like this:

<connectionStrings>
   <add name="DB" ... />
</connectionStrings>


   <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear/>
        <add name="SqlProvider" .../>
      </providers>
    </membership>
    <roleManager enabled="true">
      <providers>
        <add connectionStringName="DB"  type="System.Web.Security.SqlRoleProvider" ... />
      </providers>
    </roleManager>

The Sitemap tag is defined like this:

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true"  >
      <providers>
          <clear/>
          <add name="XmlSiteMapProvider"
            description="Default SiteMap provider."
            type="System.Web.XmlSiteMapProvider "
            siteMapFile="Web.sitemap"
            securityTrimmingEnabled="true"  />
      </providers>
  </siteMap>

Why am I getting the sql error? How does the trimming get the roles?

EDIT: the ysod

like image 646
robasta Avatar asked Feb 07 '12 08:02

robasta


1 Answers

The core error from your screenshot is

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server

unfortunatly, this is truncated. The message would normally then continue with " is configured to allow remote connections.", and this may further be followed by a specific reason (for example, it may state (amongst various other reasons) "provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified")

However, with the message you have so far, it looks like a connectivity problem between the client machine and the SQL Server box. So I'd look at doing due-diligence against the SQL Server box and network connectivity first:

  • The SQL Server server name can resolve
  • That the server can be reached with ping
  • That SQL server is configured to accept remote connections
  • That the SQL Browser service is running on the SQL Server box
  • That Windows Firewall isn't getting in the way
  • That SQL Server itself is actually running in the first place

If they pass then you need to validate than you can log-on. I'd normally use the SQL management tools, especially the command line tool sqlcmd to test basic connectivity (for example: sqlcmd -E -S mysqlserver\instance to connecto to the default database or sqlcmd -E -S mysqlserver\instance -d database to connect to a specific database). Obviously you'll need to run these as the user that your web application is running as, otherwise they'll attempt to authenticate as you (either use runas or start a command prompt under different credentials [find a command prompt in the start menu then, shift-right-click -> "Run as a different user].

However what would ultimately help would be if you can get the full error message text (rather than the truncated version), then that may help narrow down the specific problem you're having.

like image 181
Chris J Avatar answered Nov 15 '22 15:11

Chris J