Executes WS from the server with the client credentials

Hi,

I have a sikverlight 4 intranet application with RIA services.
I have a webservice (.asmx) which my application references as a WCF service.
I need that the WS will be executed from the server, but using the client credentials and not the server credentials. I somehow need to impersonate as the client. The server and the client are both in the same LAN and domain.
My question is how do I do this?

Enviroment:
Windows 7, IIS 7.5, Visual Studio 2010, Silverlight 4

My web server class that calls the WS looks like this:

    [EnableClientAccess()]
    public class DemographyDomainService : DomainService
    {

        public void GetDemography()
        {
            CustomersService.CustomersServiceClient srv = new CustomersService.CustomersServiceClient();
            CustomersService.CustomersRequest req = new tCustomersService.CustomersRequest();

            CustomersService.CustomersResponse response = srv.CustomersQuery(req);

        }

    }


My web.config looks like this;
<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
            <add name="DomainServiceModule" preCondition="managedHandler"
                type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </modules>
        <validation validateIntegratedModeConfiguration="false" />
    </system.webServer>
    <system.web>
        <httpModules>
            <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </httpModules>
        <compilation debug="true" targetFramework="4.0" />
        <authentication mode="Windows"/>
    </system.web>

    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
            multipleSiteBindingsEnabled="true" />
        <bindings>
            <basicHttpBinding>
                <binding name="CustomersService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://myurl:8089/Customers/CustomersService.asmx"
                binding="basicHttpBinding" bindingConfiguration="CustomersService"
                contract="CustomersService.CustomersService" name="CustomersService" />
        </client>
    </system.serviceModel>
</configuration>

ruvikAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ruvikAuthor Commented:
I forgot to mention that when I reference the web service as a web reference then I'm able to do exactly what I need using this code;

using( CustomersService service = new CustomersService() )
                {
                    service.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    response = service.CustomersQuery();
                }

I need this code for a WCF service.
0
ruvikAuthor Commented:
It was a problem with the web.config.
I changed the web.config and now it works.

Web.Config

<basicHttpBinding>
      <binding name="CustomersService" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="TransportCredentialOnly">
                  <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
                  <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
      </binding>
</basicHttpBinding>

<service name="SLWCF.Web.Demography">
      <endpoint address="" binding="customBinding" bindingConfiguration="CustomBinding"
            contract="SLWCF.Web.Demography" />
</service>


ClientConfig:

<bindings>
      <customBinding>
            <binding name="CustomBinding">
                  <binaryMessageEncoding />
                  <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
            </binding>
      </customBinding>
</bindings>
<client>
      <endpoint address="../Demography.svc" binding="customBinding"
            bindingConfiguration="CustomBinding" contract="Demography"
      name="CustomBinding_Demography" />
</client>

Turn off Anonymous Authentication
Turn on Windows Authentication
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.