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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans