Partilhar via


SPSecurity.SetApplicationCredentialKey Method

Sets a string that is used in encrypting and decrypting passwords.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
Public Shared Sub SetApplicationCredentialKey ( _
    password As SecureString _
)
'Usage
Dim password As SecureStringSPSecurity.SetApplicationCredentialKey(password)
public static void SetApplicationCredentialKey(
    SecureString password
)

Parameters

Remarks

The key passed as the parameter should be long and difficult to guess, just as a password is.

The key is stored in the registry.

Use the same key on all servers in the farm.

Only encrypted passwords are stored in the Microsoft SharePoint Foundation 2010 database.

Examples

This example shows how to call the SetApplicationCredentialKey method. You code file will require a using System.Security statement.

String key = "kEy5;("
SecureString secureString = new SecureString();

foreach (char ch in key)
{
    secureString.AppendChar(ch);
}

secureString.MakeReadOnly();
SPSecurity.SetApplicationCredentialKey(secureString);
Dim key As String = "kEy5;(" 
SecureString secureString = New SecureString()

For Each ch As Char In key
    secureString.AppendChar(ch)
Next ch

secureString.MakeReadOnly()
SPSecurity.SetApplicationCredentialKey(secureString)

See Also

Reference

SPSecurity Class

SPSecurity Members

Microsoft.SharePoint Namespace