Search code examples
sharepointwcfwcf-binding

SharePoint, WCF and Anonymous Access


Does a WCF service on SharePoint require that Anonymous Access is enabled?

We have an application page which is calling the service using Ajax.Net, if Anon Access is off then we get prompted for the username and password, if it is on then all is well.

We are not using a WCF client, it is purely being called by the scriptmanager

<configuration>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding
          name="webHttpBinding_DataSources"
          maxBufferSize="5242880"
          maxReceivedMessageSize="5242880" />
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior
          name="ServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior
          name="ServiceBehavior">
          <serviceMetadata
            httpGetEnabled="true"
            httpGetUrl="" />
          <serviceDebug
            includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment
      aspNetCompatibilityEnabled="true"/>
    <services>
      <service
          name="XXXXXXXX.DataSources.Services.DataSourceHelper"
          behaviorConfiguration="ServiceBehavior">
        <endpoint
          address=""
          behaviorConfiguration="ServiceAspNetAjaxBehavior"
          binding="webHttpBinding"
          bindingConfiguration="webHttpBinding_DataSources"
          contract="XXXXXXXX.DataSources.Services.IDataSourceHelper" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

Thanks, Phill


Solution

  • I managed to get it working with the following

    <configuration>
      <system.serviceModel>
        <bindings>
          <webHttpBinding>
            <binding
              name="webHttpBinding_DataSources"
              maxBufferSize="5242880"
                  maxReceivedMessageSize="5242880" >
              <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Ntlm" />
              </security>
            </binding>
          </webHttpBinding>
        </bindings>
        <behaviors>
          <endpointBehaviors>
            <behavior
              name="ServiceAspNetAjaxBehavior">
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior
              name="ServiceBehavior">
              <serviceMetadata
                httpGetEnabled="true"
                httpGetUrl="" />
              <serviceDebug
                includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment
          aspNetCompatibilityEnabled="true"/>
        <services>
          <service
              name="XXXXXXXXXX.DataSources.Services.DataSourceHelper"
              behaviorConfiguration="ServiceBehavior">
            <endpoint
              address=""
              behaviorConfiguration="ServiceAspNetAjaxBehavior"
              binding="webHttpBinding"
              bindingConfiguration="webHttpBinding_DataSources"
              contract="XXXXXXXXXX.DataSources.Services.IDataSourceHelper" />
          </service>
        </services>
      </system.serviceModel>
    </configuration>
    

    I did an IISReset and had to close and re-open my browser to get it working though

    Best Regards,

    Phill