Setting and retrieving Date Encryption key programmatically in CRM 2013
System admin can manage Data Encryption through Settings à Data Management à Data Encyrption area.
To programmatically retrieve and update the Encryption key we can use the RetrieveDataEncryptionKeyRequest and SetDataEncryptionKeyRequest
RetrieveDataEncryptionKeyRequest retrieveDataEncryptionKeyRequest = new RetrieveDataEncryptionKeyRequest();
IOrganizationService organizationService = RetrieveOrganizationService();
RetrieveDataEncryptionKeyResponse retrieveDataEncryptionKeyResponse =
(RetrieveDataEncryptionKeyResponse)organizationService.Execute(retrieveDataEncryptionKeyRequest);
MessageBox.Show(retrieveDataEncryptionKeyResponse.EncryptionKey);
SetDataEncryptionKeyRequest setDataEncryptionKeyRequest = new SetDataEncryptionKeyRequest();
setDataEncryptionKeyRequest.ChangeEncryptionKey = true;
setDataEncryptionKeyRequest.EncryptionKey = "Pass@word1";
SetDataEncryptionKeyResponse setDataEncryptionKeyResponse =
(SetDataEncryptionKeyResponse) organizationService.Execute(setDataEncryptionKeyRequest);
Cheers,
Shraddha Dhingra