This is the simplified code I use:
var endpointAddress =
new EndpointAddress("https://test/adfs/services/trust/13/usernamemixed");
var binding = new Binding();
var endpointReference = new EndpointReference("test");
WSTrustChannelFactory trustChannelFactory = new WSTrustChannelFactory(binding, endpointAddress);
trustChannelFactory.Credentials.UserName.UserName = "test";
trustChannelFactory.Credentials.UserName.Password = "test";
WSTrustChannel channel = (WSTrustChannel)trustChannelFactory.CreateChannel();
var rst = new RequestSecurityToken
{
RequestType = RequestTypes.Issue,
AppliesTo = endpointReference,
KeyType = KeyTypes.Bearer
};
RequestSecurityTokenResponse rstr = null;
try
{
SecurityToken token = channel.Issue(rst, out rstr);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
When I put wrong username or password I catch exception:
{"The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs."}
But I would like to get more specific error so that I know if this is wrong username password exception or sth different. Is there any way to configure it?