web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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)

I have the same question (0)

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

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
11manish Profile Picture

11manish 77

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 45 Super User 2026 Season 1

#3
sannavajjala87 Profile Picture

sannavajjala87 29

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans