Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have an application page and am trying to save settings for it using an SPPersistedObject. One of the fields I am saving needs to be encrypted and I tried to use SPEncryptedString but I can't get it to work.

Every time I call the UpdateSecureStringValue method to set the SPEncryptedString's SecureString with the value I need to store (after creating a SecureString with it), a SecurityException ("Access denied.") is thrown.

Can anyone tell me what I am doing wrong or possibly point me to some code that works?

share|improve this question
add comment

1 Answer 1

In order to execute method SPEncryptedString in application page, the user should be logged in as farm account (administration in server farm)

Use the following method to check whether the current user is an administrator in the server farm: CurrentUserIsAdministrator

Usage

Lets suppose we need the ability to store connection strings

  1. Create object for storing connection strings (source). Connection strings are stored as encrypted strings.
  2. And create the administration page (source for code behind). Here we use not a regular application page but an administration page.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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