microsoft / BCTech

Business Central technology samples
MIT License
555 stars 295 forks source link

BC21 Encryption Keys for SQL Server Authentication Error #171

Open sami3187 opened 1 year ago

sami3187 commented 1 year ago

if (!$RestartingInstance) {

Write-Host „Use custom user to access database“ $DatabaseUserName = „DBAdmin“ $DatabasePassword = „D$1234567“ $EncryptionPassword = „abc123ABC$%&abc123“ $TrustSQLServerCertificate = $true $ServiceTierFolder = „C:\Keys\“ $DatabaseServer = „sqlxx.database.windows.net“ $DatabaseSecurePassword = ConvertTo-SecureString -String $DatabasePassword -AsPlainText -Force $DatabaseCredentials = New-Object PSCredential -ArgumentList $DatabaseUserName, $DatabaseSecurePassword $DatabaseName = „BC210-DB“ $EncryptionKeyPath = Join-Path $ServiceTierFolder ‚BC.key‘ $EncryptionSecurePassword = ConvertTo-SecureString -String $EncryptionPassword -AsPlainText -Force New-NAVEncryptionKey -KeyPath $EncryptionKeyPath -Password $EncryptionSecurePassword -Force | Out-Null

Write-Host „Import Encryption Key“

Import-NAVEncryptionKey -ServerInstance DAF -ApplicationDatabaseServer $DatabaseServer -ApplicationDatabaseCredentials $DatabaseCredentials -ApplicationDatabaseName $DatabaseName -KeyPath $EncryptionKeyPath -Password $EncryptionSecurePassword -WarningAction SilentlyContinue -Force

Set-NAVServerConfiguration -ServerInstance „DAF“ -KeyName „EnableSqlConnectionEncryption“ -KeyValue „true“ -WarningAction SilentlyContinue Set-NAVServerConfiguration -ServerInstance „DAF“ -KeyName „TrustSQLServerCertificate“ -KeyValue $TrustSQLServerCertificate.Tostring().ToLowerInvariant() -WarningAction SilentlyContinue Set-NavServerConfiguration -serverinstance „DAF“ -databaseCredentials $DatabaseCredentials }

Any Suggestions for the below error cause.

Error :

Error

KennieNP commented 1 year ago

The error message suggests that you check which permissions the user running the PoSh script has on the database. Did you doublecheck that?

samimsc commented 1 year ago

Thanks for your reply . how to check that "check which permissions the user running the PoSh script has on the database."

samimsc commented 1 year ago

Do we need App Registrations in Azure Portal ?

samimsc commented 1 year ago

@KennieNP Could you please advise. thanks.

KennieNP commented 1 year ago

Thanks for your reply . how to check that "check which permissions the user running the PoSh script has on the database."

You can use SSMS to see users and their permissions