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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Using Default Credentials With STS

(0) ShareShare
ReportReport
Posted on by 142

I am writing a small desktop app that hooks into our company phone system and on a incoming call searches the DDI against the Contact entity and then if it finds a match offers to open the record for the user.

For security reasons we do not want to specify username and password in config files but rather use the default credentials for the logged on user. My issue is that my code works on our development server that does not use ADFS STS but it fails on our live server which does use ADFS STS. My code is below. If I use the username and password from the App Settings it works with the STS but commenting them out and using the CredentialCache causes the following error. 

{"An error occurred when processing the security tokens in the message."}

IOrganizationService _service;
OrganizationServiceProxy _serviceProxy;
ClientCredentials clientCredentials = new ClientCredentials();

//clientCredentials.UserName.UserName = ConfigurationManager.AppSettings["username"];
//clientCredentials.UserName.Password = ConfigurationManager.AppSettings["password"];

clientCredentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;

Uri organisationUri = new Uri(String.Format(ConfigurationManager.AppSettings["organisationUri"] + "XRMServices/2011/Organization.svc"));


ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertificatePolicy;

IServiceConfiguration<IOrganizationService> serviceConfiguration = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organisationUri);

serviceConfiguration.Authenticate(clientCredentials);

*This post is locked for comments

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans