Microsoft.Azure.Commands.DataFactories.DataFactoryClient.OnPremisesEncryptString C# (CSharp) Method

OnPremisesEncryptString() public method

public OnPremisesEncryptString ( SecureString value, string resourceGroupName, string dataFactoryName, string gatewayName, PSCredential credential, string type, string nonCredentialValue, string authenticationType, string serverName, string databaseName ) : string
value SecureString
resourceGroupName string
dataFactoryName string
gatewayName string
credential PSCredential
type string
nonCredentialValue string
authenticationType string
serverName string
databaseName string
return string
        public virtual string OnPremisesEncryptString(SecureString value,
            string resourceGroupName,
            string dataFactoryName,
            string gatewayName,
            PSCredential credential,
            string type,
            string nonCredentialValue,
            string authenticationType,
            string serverName, string databaseName)
        {
            LinkedServiceType linkedServiceType = type == null ? LinkedServiceType.OnPremisesSqlLinkedService : GetLinkedServiceType(type);

            if (linkedServiceType == LinkedServiceType.OnPremisesSqlLinkedService && linkedServiceType == LinkedServiceType.OnPremisesOracleLinkedService
                && linkedServiceType == LinkedServiceType.OnPremisesFileSystemLinkedService && (value == null || value.Length == 0))
            {
                throw new ArgumentNullException("value");
            }

            AuthenticationType authType = authenticationType == null ? AuthenticationType.None : (AuthenticationType)Enum.Parse(typeof(AuthenticationType), authenticationType, true);

            var response = DataPipelineManagementClient.Gateways.RetrieveConnectionInfo(resourceGroupName, dataFactoryName, gatewayName);
            var gatewayEncryptionInfos = new[]
                {
                    new GatewayEncryptionInfo
                        {
                            ServiceToken = response.ConnectionInfo.ServiceToken,
                            IdentityCertThumbprint = response.ConnectionInfo.IdentityCertThumbprint,
                            HostServiceUri = response.ConnectionInfo.HostServiceUri,
                            InstanceVersionString = response.ConnectionInfo.Version
                        }
                };

            string userName = credential != null ? credential.UserName : null;
            SecureString password = credential != null ? credential.Password : null;
            UserInputConnectionString connectionString = new UserInputConnectionString(value, nonCredentialValue, userName, password, linkedServiceType, authType, serverName, databaseName);
            return GatewayEncryptionClient.Encrypt(connectionString, gatewayEncryptionInfos);
        }

Usage Example

Ejemplo n.º 1
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture,
                                                                    Resources.DataFactoryArgumentInvalid));
                }

                DataFactoryName   = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            string encryptedValue = String.Empty;

            if (String.IsNullOrWhiteSpace(GatewayName))
            {
                // Cloud encryption without Gateway
                encryptedValue = DataFactoryClient.CloudEncryptString(Value, ResourceGroupName, DataFactoryName);
            }
            else
            {
                // On-premises encryption with Gateway
                encryptedValue = DataFactoryClient.OnPremisesEncryptString(Value, ResourceGroupName, DataFactoryName, GatewayName);
            }

            WriteObject(encryptedValue);
        }
All Usage Examples Of Microsoft.Azure.Commands.DataFactories.DataFactoryClient::OnPremisesEncryptString