custom UserName validator not being executed

H

Houston

I'm trying to use basicHttpBinding with TransportWithMessageCredential and a
custom username validator. The validator is not being executed. I'm sure
I've got a config problem but can't see where. web.config and code follow.
Thanks in advance for any help you can offer.

--Houston

--------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig">
<security mode="TransportWithMessageCredential" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ToteServiceBehavior"
name="ToteServiceLibrary.ToteDataService">
<endpoint address="mex" binding="mexHttpsBinding"
contract="IMetadataExchange" />
<endpoint address="basic" binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig"
contract="ToteServiceLibrary.iToteDataService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ToteServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate findValue="snark.mydomain.com"
storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
includeWindowsGroups="false"
customUserNamePasswordValidatorType="ToteServiceLibrary.CustomUserNameValidator,ToteServiceLibrary" />
<windowsAuthentication includeWindowsGroups="false" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="myListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="c:\inetpub\trace\SecureToteService.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
</configuration>


namespace ToteServiceLibrary
{
public bool TestSuccess()
{
return true;
}

public bool TestFailure()
{
return false;
}


public class CustomUserNameValidator : UserNamePasswordValidator
{
public override void Validate(String userName, String password)
{
if (null == userName || null == password)
{
throw new SecurityTokenException("Invalid Token");
}

if (!(userName == "user" && password == "password"))
{
throw new SecurityTokenException("Invalid Token");
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top