I have a WCF service associated with UserNamePasswordValidator through my web.config, no problem. In my validator, I override Validate, validate credentials, and throw a FaultException if necessary.
Example:
public class CredentialValidator : UserNamePasswordValidator { public override void Validate(string userName, string password) { if (userName != "dummy") { throw new FaultException<AuthenticationFault>(new AuthenticationFault(), "Invalid credentials supplied"); } } }
If I myself use this service in a .NET application and provide invalid credentials, a MessageSecurityException is thrown with the following message:
"An unsecured or incorrectly protected error was received from the other side. See the internal FaultException for the error code and details."
The FaultException I expected was an InnerException of a MessageSecurityException.
Is there a way to get the client only a FaultException?
The MessageSecurityException is not particularly descriptive with respect to the true cause of the exception (a quick SO search gives a lot of problems, including time synchronization between the server and the client), and since a third party will use this service, I like to be as clear as possible.
source share