Ch Hassan

Ch Hassan

  • NA
  • 78
  • 3.9k

how the digest authentication work

Apr 11 2014 2:00 AM
how the digest authentication work

hi
i have host wcf service on iis 6.0 and secure as digest authentication below is my server side
web.config.

<?xml version="1.0"?>
<configuration>
 

  <system.web>
    <!--<compilation debug="true" targetFramework="4.0"/>-->

    <authentication mode="None"></authentication>

  </system.web>
  <location>
    <system.webServer>
      <security>
        <authentication>
          <anonymousAuthentication enabled="false"/>
        </authentication>
      </security>
    </system.webServer>
  </location>
  <system.serviceModel>
<bindings>
      <basicHttpBinding>
        <binding name="secureBinding">
          <security mode="TransportCredentialOnly" >
            <transport clientCredentialType="Digest"
                       proxyCredentialType="Digest" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WSOnlineSales.CustomerSale" behaviorConfiguration="metadataBehavior">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="secureBinding"

            contract="WsServiceContract.ICustomer">
          <identity>

            <dns value="localhost"/>

          </identity>
        </endpoint>

        <!--<endpoint
            address="mex"
            binding="basicHttpBinding"
            contract="IMetadataExchange"/>-->
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metadataBehavior">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>



an consuming on client side like this





CustomerSale objService = new CustomerSale ();
               
                    dt.TableName = "client";
                    String MyURI = "http://url/ClientSale.svc";
                    WebRequest WReq = WebRequest.Create(MyURI);
                    WReq.Credentials = new NetworkCredential("myusername","mypass");
                    objService.UpdateSales();