I am using .net for my web application, and by hardcode username password. Sharepoint site is easily accessible.

But now i want to make some changes in application so need to login into sharepoint without passing hardcoded username and password.

Is it possible to comnect sharepoint and fetch file details by web application without passing hardcoded credentials.

** Basically my apppool user is having access for sharepoint path that i want to read file.andi want to login into sharepoint via appool user, without passing hardcoded credentials. **

Code snippet i tried but did not work :

 using (var ctx = new ClientContext(siteUrl)) { ctx.Credentials = (CredentialCache.DefaultCredentials) as SharePointOnlineCredentials; Microsoft.SharePoint.Client.Web web = ctx.Web; ctx.Load(web); ctx.ExecuteQuery(); } 

Code snippet i tried but did not work

 using (var ctx = new ClientContext(siteUrl)) { CredentialCache credCache = new CredentialCache(); credCache.Add(new Uri(siteUrl), "NTLM", CredentialCache.DefaultNetworkCredentials); ctx.Credentials = credCache; ctx.AuthenticationMode = ClientAuthenticationMode.Default; Microsoft.SharePoint.Client.Web web = ctx.Web; ctx.Load(web); ctx.ExecuteQuery(); } 

Code snippet i tried but did not work

 using (var ctx = new ClientContext(siteUrl)) { ctx.Credentials = CredentialCache.DefaultNetworkCredentials; ctx.AuthenticationMode = ClientAuthenticationMode.Default; Microsoft.SharePoint.Client.Web web = ctx.Web; ctx.Load(web); ctx.ExecuteQuery(); } 

Please help

5

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy