I currently have an app that calls a web service(WS1), which in turn calls another web service(WS2) to get/set information on the server hosted on WS2. I would like to be able to pass in the user credentials into WS2 from WS1 as if there was an application calling directly into WS2. Is there a way to do this?
This is what I have currently:
Application Code:
BasicHttpBinding basicHttpBinding =
new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
basicHttpBinding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Windows;
basicHttpBinding.MaxReceivedMessageSize = 131072000;
AppMgr.AppMgrSoapClient appMgr =
new AppMgr.AppMgrSoapClient(
basicHttpBinding,
new EndpointAddress(@"http://SomeServer/Service.asmx"));
appMgr.ClientCredentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Impersonation;
appMgr.ChannelFactory.Credentials.Windows.ClientCredential =
CredentialCache.DefaultNetworkCredentials;
appMgr.SomeWebMethodCall();
Web Service 1 code (on 'SomeServer')
BasicHttpBinding basicHttpBinding =
new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
basicHttpBinding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Windows;
basicHttpBinding.MaxReceivedMessageSize = 131072000;
WS2Service.WS2ServiceSoapClient myServiceReference =
new WS2Service.WS2ServiceSoapClient(
basicHttpBinding,
new EndpointAddress(@"http://SomeOtherServer/AnotherService.asmx"));
myServiceReference.ClientCredentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Impersonation;
myServiceReference.ChannelFactory.Credentials.Windows.ClientCredential =
CredentialCache.DefaultNetworkCredentials;
Its the last line in the Web Service code that I need to change, I know that ... but I don't know what to set it to ... There is ClientCredentials.UserName but I don't have the password at this level.