I am pass the username and password from my Silverlight 4 app to the a wcf service.
On the server side, the binding is setup as follows:
NetTcpBinding netTcpBinding = new NetTcpBinding(SecurityMode.Message, true); netTcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
and on the client side, I setup the client credentials and then call the web service:
BinaryMessageEncodingBindingElement binaryMessageEncoding = new BinaryMessageEncodingBindingElement();
TcpTransportBindingElement tcpTransport = new TcpTransportBindingElement(); binding = new CustomBinding(binaryMessageEncoding, tcpTransport);
proxy = new MyWebClient(binding, address);
proxy.ClientCredentials.UserName.UserName = "admin";
proxy.ClientCredentials.UserName.Password = "password";
proxy.Hello();
In the service's Hello() method, I retrieve the username passed from the client using the OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name. However, ServiceSecurityContext.Current is NULL.
What am I doing wrong?