Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Authentication Failed while executing query expression using organizationservice in console app, connection was successfully established

(0) ShareShare
ReportReport
Posted on by 15

Hello Everyone,

Am trying to write Console Application using C# to connect to CRM system

String url = "">company.crm.dynamics.com/.../Organization.svc";
try
{
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "company@company.com;
clientCredentials.UserName.Password = "CompanyPassword";

// For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

organizationService = (IOrganizationService)new OrganizationServiceProxy(new Uri(url), null, clientCredentials, null);

if (organizationService != null)
{

 QueryExpression querExp1 = new QueryExpression()
                                    {
                                        EntityName = "EntityName",
                                        ColumnSet = new ColumnSet("Col1", "Col2")

                                    };
                                    querExp.Criteria.AddCondition("name", ConditionOperator.Equal, value1);


                                    EntityCollection EntityList= organizationService.RetrieveMultiple(querExp); ------Error Throw

}

If i try using the above code am getting "An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."

if i see FaultException i can see "Authenticate Failure" Error

If i try using the same username and password i can able to Access the CRM System( USING AUTHENTICATION app)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Adis Profile Picture

Adis 136 Super User 2025 Season 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 81

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 77 Super User 2025 Season 1

Product updates

Dynamics 365 release plans