First attempt - using basicHttpBinding with MessageClientCredentialType of "Username". Unfortunetelly this would yield the following exception:
Second attempt - using basicHttpBinding with TransportWithMessageCredential mode.
Since this mode implies that we need to secure the transport we get any of these exceptions, depending if we are on the client or the server side:
Third attempt - using wsHttpBinding with MessageClientCredentialType of "Username".
Depending on several other settings, and wheather we're on the client or the server, we would get any of these exceptions:
Forth attempt - using wsHttpBinding with TransportWithMessageCredential mode.
Similarily to the second attempt we get:
OR
Fifth attempt - using customBinding with httpTransport and security element with authenticationMode of UserNameOverTransport
This time we get:
So it really seems like Microsoft is trying to (im)politely convince us not to use clear username/password. But what can we do for cases where this behaviour is really required?
The solution
The solution s to use ClearUsernameBinding. This binding seamlessly integrates with WCF and allows us to use clear username/password.
2 comments:
This works for :net 3.5 if you need username/password in cleartext over http
binding name="UserPasswordBinding">
security mode="TransportCredentialOnly">
transport clientCredentialType="Basic" />
/security>
/binding>
"<" removed so I could post it.
Cheers
Joakim Eriksson
Thanks Joakim.
In your case credentials are sent as HTTP headers. However it is sometimes necessary to send them in the SOAP body (as with ClearUsernameBinding).
Of course if you are planing a system from scratch and have no constraints it's better to use what you suggested.
Post a Comment