3

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?

3 Answers 3

3

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

1
  • 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...
    – empz
    Commented Dec 27, 2013 at 19:47
0

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

1
  • 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.
    – empz
    Commented Dec 27, 2013 at 18:53
0

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 and acknowledge you have read our privacy policy.

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