Security Exception with Sync Framework toolkit when running under IIS

Proposed Answer Security Exception with Sync Framework toolkit when running under IIS

  • 12 martie 2012 15:38
     
     

    I have installed the Sysnc Framework Toolkit and configured the samples ListService project as per help file (.chm).

    This works, but after trying the option "Use Local Web Server" from withIn project properties in VS2010 (first pressing "create virtual directory"), it then doesn't work and I get the following error:

    synchronisation failed: system.security.SecurityException-->.....

    ......................internalendgetresponse(IAsyncResult asyncResult)

    If I then change back to "Use Visual Studio Development Server" all works again.

    I notice that if I click debug-->exceptions-->clrexceptions-->thrown, it fails at:

    HttpCacheRequestHandler.OnDownloadGetResponseCompleted,  Stating that:

    AsyncWaitHandle = 'asyncResult.AsyncWaitHandle' threw an exception of type 'System.NotSupportedException'

    base {System.SystemException} = {System.NotSupportedException: Specified method is not supported.
       at System.Net.Browser.BHWRAsyncResult.get_AsyncWaitHandle()}

    I am using windows 7 pc, with VS2010 SP1

    Also if helps my diag$ is all fine when run under VS2010 web server, but when show for IIS it says:

    ClientAccessPolicy.xml/CrossDomain.xml files FAILED                   Could not find clientaccesspolicy.xml or crossdomain.xml file. Silverlight clients invoking the service from another domain will                  be unable to make requests successfully.                 

    running in fiddler i can see the following details for clientaccesspolicy files:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>IIS 7.5 Detailed Error - 401.2 - Unauthorized</title>
    <style type="text/css">
    <!--
    body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;background:#CBE1EF;}
    code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;}
    .config_source code{font-size:.8em;color:#000000;}
    pre{margin:0;font-size:1.4em;word-wrap:break-word;}
    ul,ol{margin:10px 0 10px 40px;}
    ul.first,ol.first{margin-}
    fieldset{padding:0 15px 10px 15px;}
    .summary-container fieldset{padding-bottom:5px;margin-}
    legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;}
    legend{color:#333333;padding:4px 15px 4px 10px;margin:4px 0 8px -12px;_margin-
     border-border-border-right:1px solid #969696;
     border-bottom:1px solid #969696;background:#E7ECF0;font-weight:bold;font-size:1em;}
    a:link,a:visited{color:#007EFF;font-weight:bold;}
    a:hover{text-decoration:none;}
    h1{font-size:2.4em;margin:0;color:#FFF;}
    h2{font-size:1.7em;margin:0;color:#CC0000;}
    h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;}
    h4{font-size:1.2em;margin:10px 0 5px 0;
    }#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif;
     color:#FFF;background-color:#5C87B2;
    }#content{margin:0 0 0 2%;}
    .summary-container,.content-container{background:#FFF;width:96%;margin-padding:10px;}
    .config_source{background:#fff5c4;}
    .content-container p{margin:0 0 10px 0;
    }#details-left{width:35%;float:left;margin-right:2%;
    }#details-right{width:63%;float:left;
    }#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF;
     background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-font-weight:normal;
     font-size:1em;color:#FFF;text-align:right;
    }#server_version p{margin:5px 0;}
    table{margin:4px 0 4px 0;width:100%;border:none;}
    td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:bold;border:none;}
    th{width:30%;text-align:right;padding-right:2%;font-weight:normal;}
    thead th{background-color:#ebebeb;width:25%;
    }#details-right th{width:20%;}
    table tr.alt td,table tr.alt th{background-color:#ebebeb;}
    .highlight-code{color:#CC0000;font-weight:bold;font-style:italic;}
    .clear{clear:both;}
    .preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;}
    -->
    </style>
     
    </head>
    <body>
    <div id="header"><h1>Server Error in Application "DEFAULT WEB SITE"</h1></div>
    <div id="server_version"><p>Internet Information Services 7.5</p></div>
    <div id="content">
    <div class="content-container">
     <fieldset><legend>Error Summary</legend>
      <h2>HTTP Error 401.2 - Unauthorized</h2>
      <h3>You are not authorized to view this page due to invalid authentication headers.</h3>
     </fieldset>
    </div>
    <div class="content-container">
     <fieldset><legend>Detailed Error Information</legend>
      <div id="details-left">
       <table border="0" cellpadding="0" cellspacing="0">
        <tr class="alt"><th>Module</th><td>IIS Web Core</td></tr>
        <tr><th>Notification</th><td>AuthenticateRequest</td></tr>
        <tr class="alt"><th>Handler</th><td>StaticFile</td></tr>
        <tr><th>Error Code</th><td>0x80070005</td></tr>
        
       </table>
      </div>
      <div id="details-right">
       <table border="0" cellpadding="0" cellspacing="0">
        <tr class="alt"><th>Requested URL</th><td>http://localhost:80/crossdomain.xml</td></tr>
        <tr><th>Physical Path</th><td>C:\inetpub\wwwroot\crossdomain.xml</td></tr>
        <tr class="alt"><th>Logon Method</th><td>Not yet determined</td></tr>
        <tr><th>Logon User</th><td>Not yet determined</td></tr>
        
       </table>
       <div class="clear"></div>
      </div>
     </fieldset>
    </div>
    <div class="content-container">
     <fieldset><legend>Most likely causes:</legend>
      <ul>  <li>No authentication protocol (including anonymous) is selected in IIS.</li>  <li>Only integrated authentication is enabled, and a client browser was used that does not support integrated authentication.</li>  <li>Integrated authentication is enabled and the request was sent through a proxy that changed the authentication headers before they reach the Web server.</li>  <li>The Web server is not configured for anonymous access and a required authorization header was not received.</li>  <li>The "configuration/system.webServer/authorization" configuration section may be explicitly denying the user access.</li> </ul>
     </fieldset>
    </div>
    <div class="content-container">
     <fieldset><legend>Things you can try:</legend>
      <ul>  <li>Verify the authentication setting for the resource and then try requesting the resource using that authentication method.</li>  <li>Verify that the client browser supports Integrated authentication.</li>  <li>Verify that the request is not going through a proxy when Integrated authentication is used.</li>  <li>Verify that the user is not explicitly denied access in the "configuration/system.webServer/authorization" configuration section.</li>  <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="herehttp://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul>
     </fieldset>
    </div>
     
     
    <div class="content-container">
     <fieldset><legend>Links and More Information</legend>
      This error occurs when the WWW-Authenticate header sent to the Web server is not supported by the server configuration. Check the authentication method for the resource, and verify which authentication method the client used. The error occurs when the authentication methods are different. To determine which type of authentication the client is using, check the authentication settings for the client.
      <p><a href="View">http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=401,2,0x80070005,7600">View more information &raquo;</a></p>
      <p>Microsoft Knowledge Base Articles:</p>
     <ul><li>907273</li><li>253667</li></ul>
     
     </fieldset>
    </div>
    </div>
    </body>
    </html>

    • Editat de waynerw 12 martie 2012 16:12
    •  

Toate mesajele

  • 13 martie 2012 01:41
    Moderator
     
     
  • 13 martie 2012 10:42
     
     

    Hi Yes I did have all these

    The way it was fixed was by making the default website authentication to 'windows authentication', then this worked?

    Is there any guidance on how to deploy this to an external server, as I will not be able to have windows authentication set for an internet based application?

  • 13 martie 2012 11:20
    Moderator
     
     
    unfortunately, the link above is probably the only documentation you'll find on the IIS deployment part as far as Sync Toolkit is concerned. that being said, you can follow any SL+WCF best practices on deployment.
  • 13 martie 2012 11:36
     
     

     I have looked at wcf deployement guides, and I seem to do everything right.

    As per guides  I tried wcftestclient.exe, as from what I understand this is what is used to test wcf services, but when i run it says the error below.

    I am right in thinking that wcftestclient should work woith this eaxmple, and if so why not, is it because it is built under .net 2.0?

    Error: Cannot obtain Metadata from http://localhost/ListService/DefaultScopeSyncService.SVC

    If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.

    WS-Metadata Exchange Error
        URI: http://localhost/ListService/DefaultScopeSyncService.SVC

        Metadata contains a reference that cannot be resolved: 'http://localhost/ListService/DefaultScopeSyncService.SVC'.

        The remote server returned an unexpected response: (400) Bad Request.

        The remote server returned an error: (400) Bad Request.

    HTTP GET Error
        URI: http://localhost/ListService/DefaultScopeSyncService.SVC

        The document at the url http://localhost/ListService/DefaultScopeSyncService.SVC/$syncscopes was not recognized as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'Discovery document at the URL http://localhost/ListService/DefaultScopeSyncService.SVC/$syncscopes could not be found.'.
      - The document format is not recognized.
    - Report from 'WSDL Document' is 'There is an error in XML document (1, 2).'.
      - <service xmlns='http://www.w3.org/2007/app'> was not expected.
    - Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.

  • 13 martie 2012 12:15
    Moderator
     
     
    is metadata publishing enabled on the config file?
  • 13 martie 2012 15:13
     
     

    Hi Yeh the webconfig is as:

    <system.serviceModel>
      <behaviors>
        <serviceBehaviors>
          <behavior name="SimpleServiceBehavior">
            <serviceMetadata httpGetEnabled="True" policyVersion="Policy12" />
            <serviceDebug includeExceptionDetailInFaults="False" />
          </behavior>
        </serviceBehaviors>
      </behaviors>
    </system.serviceModel>

    but running wcftestclient still gives the error below, I noticed that is is expecting a different root element than what syncscopes gives, i.e. it is expecting <schema>, whereas this gives:   - <service xmlns='http://www.w3.org/2007/app'>

    I take it wcftestclient should work with this as other wcf services?

    Error: Cannot obtain Metadata from http://localhost/ListService/DefaultScopeSyncService.SVC

    If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.

    WS-Metadata Exchange Error
        URI: http://localhost/ListService/DefaultScopeSyncService.SVC

        Metadata contains a reference that cannot be resolved: 'http://localhost/ListService/DefaultScopeSyncService.SVC'.

        The remote server returned an unexpected response: (400) Bad Request.

        The remote server returned an error: (400) Bad Request.

    HTTP GET Error
        URI: http://localhost/ListService/DefaultScopeSyncService.SVC

        The document at the url http://localhost/ListService/DefaultScopeSyncService.SVC/$syncscopes was not recognized as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'Discovery document at the URL http://localhost/ListService/DefaultScopeSyncService.SVC/$syncscopes could not be found.'.
      - The document format is not recognized.
    - Report from 'WSDL Document' is 'There is an error in XML document (1, 2).'.
      - <service xmlns='http://www.w3.org/2007/app'> was not expected.
    - Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.

  • 18 aprilie 2012 16:38
     
     Răspuns propus
    Hi this now works, simply followed all details in help file more clearly in particular installing the server versions of the sync software
    • Propus ca răspuns de xcfrt 18 aprilie 2012 16:38
    •