I am developing a single C # application that is used to extract data from Dynamics CRM Online. To verify the username and password in CRM Dynamics, I use WhoAmIRequest. It works fine until the script below appears.
1) Connect Dynamics CRM with a valid URL, username and password.
2) Delete the organizationβs service object.
3) Reconnect Dynamics CRM with a valid URL, username, and invalid password.
In this case, WhoAmIRequest also successfully completed. But he must fail.
The following is the code I'm using:
private void button6_Click(object sender, EventArgs e) { CrmConnection connection; string url = "Url=https://mytest.crm.dynamics.com ; Username=mytest@mytest.onmicrosoft.com ; Password=goodpassword;"; connection = CrmConnection.Parse(url); OrganizationService orgService = new OrganizationService(connection); Guid userid = ((WhoAmIResponse)orgService.Execute(new WhoAmIRequest())).UserId; if (userid == null) MessageBox.Show("Login Failed"); else MessageBox.Show("Login Success"); orgService.Dispose(); url = "Url=https://mytest.crm.dynamics.com ; Username=mytest@mytest.onmicrosoft.com ; Password=badpassword;"; connection = CrmConnection.Parse(url); orgService = new OrganizationService(connection); userid = ((WhoAmIResponse)orgService.Execute(new WhoAmIRequest())).UserId; if (userid == null) MessageBox.Show("Login Failed"); else MessageBox.Show("Login Success"); orgService.Dispose(); url = "Url=https://mytest.crm.dynamics.com ; Username=mytest@mytest.onmicrosoft.com ; Password=goodpassowrd;"; connection = CrmConnection.Parse(url); orgService = new OrganizationService(connection); userid = ((WhoAmIResponse)orgService.Execute(new WhoAmIRequest())).UserId; if (userid == null) MessageBox.Show("Login Failed"); else MessageBox.Show("Login Success"); orgService.Dispose(); }
The code output above shows 3 message boxes as
Login Success
Login Success
Login Success
But it should display as
Login Success
Login failed
Login Success
I also tried to suggest Nicknow's answer in Need to verify CRM credentials Question, but nothing helps
Any help would be greatly appreciated.
Thanks and Regards Venkatesan
source share