dynamics crm - Need to validate CRM credentials -


My goal is simple, how do I check the URL, user name, password and domain using Dynamics CRM 2013 API Can the values ​​be valid?

I have a custom application that will use the API. I have a setup screen where the user will enter the URL, user name, password and domain. I have a button that is called "Test Connection", it will confirm that it can connect using that information.

Here I am using to create arguments:

  string connectionString; If (_crmDomain! = "") ConnectionString = string.Format (@ "Url = {0}; Username = {1} \ {2}; Password = {3}", URL, Domain, Username, Password); Else connectionString = string.format (@ "Url = {0}; Username = {1}; password = {2}", URL, Username, password); Var CSS = New connection string settings ("CRMonnectionString", connectionString); Var cn = new CrmConnection (CSS); Var service = new organization service (CN);   

The issue is that even if the credentials are invalid (maybe the wrong password), the new organization creates a service that does the line work fine, is there any way to check that when a real call It is made, then will it work?

Now I'm getting around it by calling a dummy. It forces it to make connections. Here's what I'm doing:

  var request = Retrieve all Entiants (); Request.EntityFilters = EntityFilters.Entity; Service.Execute (request);   

Service if the credentials are not valid. Execute line throws an exception. It works fine with a problem. Let's say that the user had entered a valid identity and successfully clicked on the test connection. Now say that they change the password to be wrong and click on the test connection. Do it. In this case it is still successful, it seems to be using the already existing connection. Is there a way to erase or clear the previous connection, when I try it with invalid values, it will throw an exception?

Then, my overall goal is to validate the login value, which will provide the best way to accomplish whatever is what I am thank you!

Use the connection string settings and CrmConnection's Use the. Pars () .

  var cn = CrmConnection.Parse (connectionString); Var service = new organization service (CN); Try {service.Execute (New WhoAmIRequest ()); } Hold (exception before) {// something because the connection setup was bad}   

Renew

I ran the following code and got it Expected output is shown below the code. When the password is changed to a bad password, the request fails and when it is converted to a good password it succeeds.

  var connectionString = @ "Url = https: //server.com/orgname/; username = domain \ username \ password = good password;"; Var cn = CrmConnection.Parse (connectionString); Var Service = New Organization Service (CN); Try {service.Execute (new WhoAmIRequest ()); Console "Written" ("good password"); } Hold {Console.WriteLine ("bad password"); } ConnectionString = @ "Url = https: //server.com/orgname/; Username = Domain \ Username; Password = Wrong Password;"; Cn = CrmConnection.Parse (connectionString); Service = New Organization Service (CN); Try {service.Execute (new WhoAmIRequest ()); Console "Written" ("good password"); } Hold {Console.WriteLine ("bad password"); } ConnectionString = @ "Url = https: //server.com/orgname/; Username = Domain \ Username; Password = Good password;"; Cn = CrmConnection.Parse (connectionString); Service = New Organization Service (CN); Try {service.Execute (new WhoAmIRequest ()); Console "Written" ("good password"); } Hold {Console.WriteLine ("bad password"); }   

The output for the console is:

  good password bad password good password    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -