Campey
Campey

Reputation: 1158

Dynamics CRM 2011 - Determine the type of Authentication Issue

I presume this is by design (and hence might be a silly question) however is there any way to determine the authentication issue generated when connecting to Dynamics CRM.

I am creating a third party application which connects and I would like to say "Invalid Password" rather than "Authentication Failure". The following is what I have.

namespace MyCRM
{
public class MyCRMClass
{
    public static void ConnectToCRM()
    {
        Uri serverURI = new Uri('https://myorganisation.api.crm5.dynamics.com/XrmServices/2011/Organization.svc');
        ClientCredentials clientCredentials = new ClientCredentials();
        clientCredentials.UserName.UserName = 'Username';
        clientCredentials.UserName.Password = 'Password';

        OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(serverURI, null, clientCredentials, null);
        serviceProxy.EnableProxyTypes();

        try
        {
            Guid UserId = ((WhoAmIResponse)serviceProxy.Execute(new WhoAmIRequest())).UserId;
        }
        catch (Exception ex)
        {
            // Throws Authentication Issue
        }
    }
}
}

By calling the WhoAMIRequest I can get an Authentication error however I really want to know what error so I can assist staff with fixing their own issue.

Am I right in suggesting that this is not possible using the CRM webservices?

Upvotes: 0

Views: 538

Answers (1)

Daryl
Daryl

Reputation: 18895

You'll never be able to get error information like you're requesting from the client side. You could theoretically turn on trace logging on the server, but that would be a bad idea for a whole slew of reasons.

Generally saying the password is invalid is a security issue because it allows hackers to know that the account is valid and if they could just figure out the password, they're in.

Upvotes: 1

Related Questions