Quantcast
Viewing all articles
Browse latest Browse all 10096

CSOM calls with Default Network Credentials

Hi Folks,

I am trying to make CSOM calls from a Windows .NET(C#) application to a SharePoint Online Tenant. It works well with "SharePointOnlineCredentials".

However, If I try to make the same CSOM call with Windows Integrated Authentication mode by using "DefaultNetworkCredentials", CSOM call does not work and it gives (401) Unauthorized error (Even though the logged in user is a Tenant Admin). 

Thus, Is there a way to make CSOM calls to a SharePoint Online Tenant using Logged in User's credential?

Further, following is the code snippet I use to make these CSOM calls.

ClientContext ctx = new ClientContext(SiteURL);
ctx.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
ctx.AuthenticationMode = ClientAuthenticationMode.Default;
ctx.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(ctx_MixedAuthRequest);
Web web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();

Thanks & Regards,

Handun.



Viewing all articles
Browse latest Browse all 10096

Trending Articles