I have a Sharepoint 2013 provider-hosted app that gets installed (along with a custom WCF Sharepoint-hosted service) using a powershell script. This script also creates a SQL Server database that the app uses to store some data. After the database is created, an sql login and user is created and a connection string is generated.

The question is, where to store this connection string so the app can get it?

Since is kind of sensitive information, I'd like a place that's only accessible via server-side code.

Any suggestions?


You can programmatically add/update AppSettings to the web.config file. You could store your connection string in an AppSetting string...

  • Yes but the script that creates the database is a powershell script. And it runs before the app is installed, so there's no web.config... – emzero Dec 27 '13 at 19:47

For SharePoint 2010 and up, you can actually store your credentials in the Secure Store Service, then programatically access as needed using the SharePoint Object Model.

Here is a link including instructions on how to achieve this: CLICK HERE

  • I don't think that's going to work in a provider hosted app. The code from the link includes things like SPSecurity.RunWithElevatedPrivileges which is clearly not available in a Sharepoint App. – emzero Dec 27 '13 at 18:53

I ended up storing it in the Site collection property bag.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.