I have a task schedular in which i am connceting to sharepoint site and fetching some data using csom script c# and after processing sending the mails to users.
i am creating the context by passing user credential which are stored in app.config file as below code.
ClientContext context = new ClientContext(siteUrl);
context.RequestTimeout = int.MaxValue;
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
var credentials = new NetworkCredential(siteUserName, siteUserPassword, siteDomain);
Web web = context.Web;
context.Load(web, w => w.Title);
context.Credentials = credentials;
return context;
how we can store these credentials other than config file for security?
You can store the credentials in a database, and retrieve them when you want to create the ClientContext.