c# - Credentials passed from client to WCF do not make it there -
im trying pass windows credentials wcf service requires windows authentication seems credentials not making service. service not throw errors when check either of 2 below empty. var user = windowsidentity.getcurrent().user; var callerusername = servicesecuritycontext.current.windowsidentity.user;
here client side code servicereference1.dispatchserviceclient service = new dispatchserviceclient(); service.clientcredentials.windows.clientcredential = servicecredentialsmanager.getnetworkcredentials(); service.clientcredentials.username.username= servicecredentialsmanager.getnetworkcredentials().username; service.clientcredentials.username.password = servicecredentialsmanager.getnetworkcredentials().password;
client config -
<basichttpbinding> <binding name="basichttpsbinding_idispatchservice"> <security mode="transport"> <transport clientcredentialtype="windows" /> </security> </binding> </basichttpbinding> <basichttpsbinding> <binding name="basichttpsbindingmax" maxbuffersize="999999999" maxreceivedmessagesize="999999999"> <security mode="transport"> <transport clientcredentialtype="windows" /> </security> </binding> </basichttpsbinding> </bindings>
service config -
<system.servicemodel> <bindings> <basichttpbinding> <binding name="basichttpsbinding"> <security mode="transport"> <transport clientcredentialtype="windows" /> </security> </binding> </basichttpbinding> </bindings> <behaviors> <servicebehaviors> <behavior> <!-- avoid disclosing metadata information, set values below false before deployment --> <servicemetadata httpgetenabled="true" httpsgetenabled="true" /> <!-- receive exception details in faults debugging purposes, set value below true. set false before deployment avoid disclosing exception information --> <servicedebug includeexceptiondetailinfaults="true" /> </behavior> </servicebehaviors> </behaviors> <protocolmapping> <add binding="basichttpsbinding" scheme="https" /> </protocolmapping> <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" />
please note in order use windows authentication both service , client application has run in same windows domain.
please make sure that in client values assign not empty. usually, password isn't accessible code when windows authentication used.
if service client authenticated using windows authentication, shouldn't manually pass credentials service. authentication process should handled automatically wcf , doesn't rely on sending credentials, example can use kerberos ticket instead.
please take here description , code samples client , service:
- https://msdn.microsoft.com/en-us/library/ms734673%28v=vs.110%29.aspx
- https://msdn.microsoft.com/en-us/library/ms733089%28v=vs.110%29.aspx
update
after research i've found several sources suggesting setting credentials appripriately in client code may enable wcf authenticate outside domain:
- https://devdump.wordpress.com/2009/04/29/wcf-windows-authentication-and-external-users/
- http://subbusspace.blogspot.com/2009/10/accessing-wshttp-wcf-service-from.html
the code samples suggested in articles similar, different 1 you've posted in question. haven't tested methods , may not work in scenarios.
Comments
Post a Comment