[Mono-list] WCF - ServiceSecurityContext

rjhdakota rjh at homeseer.com
Wed Feb 16 11:33:47 EST 2011

I am having what I believe is the same problem. You say basic authentication
is working, any examples? Our project needs the ability to authorize a
connection, and currently we cannot. Here is the code that works on Windows
but allows anyone to connect on MONO: 

Public Sub WCFStartService() 
        ' http service, one-way 

        Dim binding = New
        binding.Security.Transport.ClientCredentialType =

        Dim address = New Uri("") 
        ServiceHost = New ServiceHost(GetType(HelloService)) 

= Security.UserNamePasswordValidationMode.Custom 
= New CustomUserNameValidator 

        ServiceHost.AddServiceEndpoint(GetType(IHelloService), binding,
    End Sub 

Public Class CustomUserNameValidator 
        Inherits IdentityModel.Selectors.UserNamePasswordValidator 

        Public Overrides Sub Validate(ByVal userName As String, ByVal
password As String) 
            If Nothing = userName OrElse Nothing = password Then 
                Throw New ArgumentNullException() 
            End If 

            If Not (userName = "user" AndAlso password = "pass") Then 
                ' This throws an informative fault to the client. 
                Throw New FaultException("Unknown Username or Incorrect
                ' When you do not want to throw an infomative fault to the
                ' throw the following exception. 
                ' Throw New SecurityTokenException("Unknown Username or
Incorrect Password") 
            End If 

        End Sub 

    End Class
View this message in context: http://mono.1490590.n4.nabble.com/WCF-ServiceSecurityContext-tp3307343p3309204.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list