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 :
Customer experience | Sales, Customer Insights,...
Answered

Is it possible to use current windows user credentials for new OrganizationServiceProxy connection to Dynamics 365 instance?

(0) ShareShare
ReportReport
Posted on by 10

Is it possible to use current windows user credentials for new OrganizationServiceProxy connection to Dynamics 365 instance?

ClientCredentials credentials = new ClientCredentials();
//credentials.UserName.UserName = username;
//credentials.UserName.Password = password;

Uri organizationUri = new Uri(serviceUrl);
Uri homeRealmUri = null;

// set default credentials for OrganizationService
credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
// or
//credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;

OrganizationProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);

However this throws this:

System.ArgumentNullException: Value cannot be null.
Parameter name: ClientCredentials.UserName.UserName

I have the same question (0)
  • Verified answer
    sardar ahmed Profile Picture
    520 on at

    Hi Andrew,

    What instance of d365 you have?, is it on-premise or online. for online instance windows authentication is not supported. follow the below link for more details

    docs.microsoft.com/.../sample-authenticate-users-web-services

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 > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 96

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 69 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans