Quantcast
Channel: SQL Server Security forum
Viewing all 3027 articles
Browse latest View live

Always encrypted

$
0
0

I encountered the following error while attempting to insert using tsql in ssms into the table which has an always encrypted column.

Operand type clash: varchar is incompatible with varchar(20) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'training') collation_name = 'SQL_Latin1_General_CP1_CI_AS'


I want assign variable value to another variable which is in different powershell script

$
0
0

Hi 

I want to know how to assign variable value to another variable which is different powershell in diferent location 

for eg

The below Test.ps1 is present in  D:/.....power--folder

Test.ps1

$sqlserver="servername"

$DB="DBName"

establishing connection

xxxxxxxx

Close()

he below Test.ps1 is present in  D:/..... /diferent/--folder

Test2.ps1

$sql="??" 

$DD="??"

(??=sqlserver value in test.ps1) 

i want assign same sqlserver value in test.ps1 to test2.ps1 variable values

How to Encrypt Data on a Sql Server 2008 R2 Database ?

$
0
0


I have a .NET Application which connects to a SQL Server 2008 R2 Database.

Now, a customer asks if every data on the DB could be encrypted.

The purpose should be to have a Database only usable by the .NET Application, and also by a sort of "power user", from SQL Server Management Studio...

Don't know if it's possible or not. Keep in mind i'm NOT into Database Encryption, so my questions are very smple.

Thanks to anyone able to help.


sql query to get all users of a particular Active Directory group

$
0
0

Hi All,

I wanted to write a sql query to return all the users from a specific AD Group specifying the Group Name instead of the CN value in memberof.

I have written the query as shown below. kIndly help me on the same :

SELECT sAMAccountName as Login 
FROM OPENQUERY( ADSI, 
'SELECT sAMAccountname FROM ''LDAP:// DC=<<MyDomainName>>,DC=com'' 
WHERE objectCategory=''person'' AND objectClass=''user''  AND memberOf=''CN=<<MyGroupName>>,OU=BI,OU=Administrator Accounts,OU=MIS,OU=Corporate Users,DC=<<MyDomainName>>,DC=com''')

Kindly help me on the same

Thanks


ram

Connecting to SQL Azure via Powershell

$
0
0

I am trying to connect to SQL Azure via powershell connection strings. I have no issue connecting using a local SQL Server account but when I try to use Azure Active directory I get a login failed or cannot connect to server. I have setup the AAD user as a contained database user and am able to connect to the Azure database via SSMS using all forms of authentication. MFA, with password and Integrated. Here is the code I use

function Get-SqLOLEDBData ($SQLconnString, $SQLqry) {
$SQLconnString
$OLEDBConn = New-Object System.Data.OleDb.OleDbConnection($SQLconnString)
$OLEDBConn.open()
$readcmd = New-Object system.Data.OleDb.OleDbCommand($SQLqry,$OLEDBConn)
$readcmd.CommandTimeout = "300"
$da = New-Object system.Data.OleDb.OleDbDataAdapter($readcmd)
$dt = New-Object system.Data.datatable
[void]$da.fill($dt)
$OLEDBConn.close()
return $dt
}

$SQLqry = 'select * from dbo.mytable'

$SQLconnString = 'Data Source=myserver.database.windows.net;Initial Catalog=mydatabase;Authentication=ActiveDirectoryPassword;User Id=myuser@mydomain.com;Password=mypassword;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;Provider=SQLNCLI11'

$DB_Results = Get-SqLOLEDBData "$SQLconnString" $SQLqry
$DB_Results

if i try connect this way, the @ symbol in the username thinks its trying to connect the user to mydomain.com which clearly doesn't exist. 

If I change the User ID = svcAzSQLfacuat@mydomain.com@myserver or svcAzSQLfacuat@mydomain.com@myserver.database.windows.net

I get a Login failed for user svcAzSQLfacuat@mydomain.com but like I said I can connect via ssms with the same username and password i am passing in the connection string. 

Any help is greatly appreciated. 


Meachel Carnahan BSc. Computer Science Database Administrator


Using Always Encrypted

$
0
0

Hi, I’m using sql 2016 Always Encrypted.

I have a column called PinNumber nvarchar(60)

The column is encrypted, but I received an error;

Operand type clash: nvarchar(60) is incompatible with nvarchar(60) encrypted with (encryption_type = 'DETERMINISTIC',

If I change the column tonvarchar(Max) everything works ok.

If I use encryption do I need to set the field size to nvarchar(Max) or am I doing something wrong?

SQL Server Agent service won't start

$
0
0

Hello,

Version: MS SQL Server 2016

I had a problem with some folder rights that couldn't be accessed from a stored procedure which was running as a job on the SQL Server Agent. Then I tried changing the SQL Server Agent service logon account to "Built-in account" Local System... that helped, but then some other things didn't work.

Wanted to change it back..., but seems like I need a password to alter the logon for the service. I do not have a password for NT Service\SQLSERVERAGENT.

I use the SQL Server Configuration Manager application to make the changes. WHen I type in the NT Service\SQLSERVERAGENT as Account Name and leave the password input boxes empty and click on the Apply button I get an dialogbox with a message "The Parameter is incorrect. [0x80070057]". Already Googled that, but it didn't reveal any answers towards my problem.

Hope that some one can be of any help, the only thing I need is to get the SQL Server Agent running as it did before I tried with a different logon accountname.


Br,

René Fisker


How to remove SQL Server 2000 error log?

$
0
0

Dears,

How to remove SQL Server 2000 error log


谷青松


SQL Server Service Run

$
0
0

Hi,

I am dealing with a repetitive error.

1. In my company, service of installed SQL Server Database Engine on my computer often stops.

2. The same issue occurs also on SSRS.

3. Since we have change passwords due to information security. I also have to make request from technical department to redefine my password to SSRS Configuration Manager. 

Moreover, since I work in a big company I cannot make arrangements on those services, I request it from technical department and make demands.

I've searched forum about the problem, however found no satisfying answer. I wonder that is it possible that technical department give me authorization to start those without being admin?

Kind Regards,

Create New Schema and Grant User Full Control to Schema

$
0
0

Hello Everyone,

I have a database that is split into 6 schemas.  Each schema has an owner that will need permissions to create/edit/delete tables, views, stored procedures within there schema only.  They pretty much will have complete control over their own schema.  They cannot create or modify any other objects outside there schema.   I am struggling to configure this role in SQL Server 2008 R2.  Can anyone please help me write a script that creates this role?

Thank you in advanced.

Sam

Enable Always Encrypted column encryption using powershell throws exception

$
0
0

Hi,

SSMS 17.6 (version 14.0.17230.0) running on Windows server 2012 R2 has been used to generate the scripts (Powershell) to enable column encryption throughout our environments, against  Sql Server 2016 Service Pack 1 + (KB3182545), but when attempting to run the powershell scripts it fails with the below .   

Does anyone have any suggestions ?  given this is a default installation 

PS C:\Windows\system32> C:\Users\msmith2\Downloads\Test_MartinEncypted_onecolumn.ps1
Set-SqlColumnEncryption : The type initializer for 'Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager' 
threw an exception.
At C:\Users\msmith2\Downloads\Test_MartinEncypted_onecolumn.ps1:23 char:1+ Set-SqlColumnEncryption -ColumnEncryptionSettings $encryptionChanges  ...+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : NotSpecified: (:) [Set-SqlColumnEncryption], TypeInitializationException+ FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.SqlServer.Management.PowerShell.AlwaysEncrypted.SetCol 
   umnEncryption

PS C:\Windows\system32> $error[0]|format-list -force


Exception             : System.TypeInitializationException: The type initializer for 
                        'Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager' threw an exception. ---> 
                        System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
                        ---> System.TypeInitializationException: The type initializer for 
                        'Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement' threw an exception. 
                        ---> System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, 
                        Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the 
                        file specified.
                           at 
                        Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement.get_CustomProviders()
                           at Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement..cctor()
                           --- End of inner exception stack trace ---
                           at 
                        Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement.get_CustomProviders()
                           --- End of inner exception stack trace ---
                           at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean 
                        constructor)
                           at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] 
                        arguments)
                           at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, 
                        Object[] parameters, CultureInfo culture)
                           at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
                           at Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager.get_CustomProviders()
                           at Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager..cctor()
                           --- End of inner exception stack trace ---
                           at Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager.add_EncryptionProgressCh
                        anged(EventHandler`1 value)
                           at 
                        Microsoft.SqlServer.Management.PowerShell.AlwaysEncrypted.SetColumnEncryption.InitializeObject(Database 
                        db)
                           at 
                        Microsoft.SqlServer.Management.PowerShell.AlwaysEncryptedRotationCmdlet`1.ProcessTarget(SmoRecordContext 
                        target)
                           at Microsoft.SqlServer.Management.PowerShell.SqlCmdlet`1.ProcessRecord()
                           at Microsoft.SqlServer.Management.PowerShell.SmoCmdlet.ProcessRecord()
                           at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          : 
CategoryInfo          : NotSpecified: (:) [Set-SqlColumnEncryption], TypeInitializationException
FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.SqlServer.Management.PowerShell.AlwaysEncrypted.SetColumnEncr
                        yption
ErrorDetails          : 
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, C:\Users\msmith2\Downloads\Test_MartinEncypted_onecolumn.ps1: line 23
PipelineIterationInfo : {}
PSMessageDetails      : 




PS C:\Windows\system32> 

Application Roles does not restore from SQL Server 2012 backup onto SQL Server 2014

$
0
0
Is this a known issue?  Where if you have a SQL Server 2012 backup with a SQL Application Roles setup and then restore the backup onto SQL Server 2014 does not restore the SQL Application Roles.  So I had to create the database with the SQL Application Roles on to SQL Server 2014 and did a backup and with that it obviously restored the SQL Application Roles when restored onto another SQL Server 2014 instance. 

Unable to patch CVE-2016-xxx - SQL

$
0
0

Hello, 

I've been trying to patch CVE-2016-7250 - MS16-136 - Microsoft - SQL  and CVE-2016-7253 - MS16-136 - Microsoft - SQL on one of our SQL servers with no success. 

Here are some details on the server, SQL Server 2014 (SP2)

It's on the latest version with the latest cumulative update 13 for SQL Server 2014 SP2 - KB4456287 which should patch this vulnerability, but when i run a pen-test both of these vulnerabilities keep pooping up. Has anyone encountered this? 

How many copies and where a database master key was stored?

$
0
0

I created a DMK with a password. according to document Here, 

"a copy of the key is encrypted by using the service master key and stored in both the database and in master"

My understanding is 2 copies were created, one saved in Database where the DMK was created, another saved in master DB.

Further in this document:

"When it is created, the master key is encrypted by using the AES_256 algorithm and a user-supplied password"

Based on this, my understanding is one more copy of the key exists in the Database where it was created.

So, there are total 3 copies of DMK were created, 2 encrypted by SMK (one in database, another in master), and 1 in user database. Is this right?

Thank you!

Always Encrypted using like operator

$
0
0

Hi,

I would like to use the "Like" operator in order to search within an encrypted field. Is this possible? Any alternatives?

Please find below some cases 

Case 1: It works 

Declare @name nvarchar(200)='Greg'
select c.name from Customers 
where name  =@name

Case 2: It doesn't work with like

Declare @name nvarchar(200)='Greg'
select c.name from Customers 
where name  like @name

Case 3: I want to search for all the name starting with Gr

Declare @name nvarchar(200)='Gr*'
select c.name from Customers 
where name  like Replace(@name, '*', '%')

Thank you in advance



FAILED TO GET FULL HISTORY OF SQL QUERIES RUN BY USER ON THE DATABASE SQL SERVER 2014 .

$
0
0
Greetings!!

Kindly assist to get full history of all sql queries run by user on the database sql server 2014 since first logged in.

Thank you!!!

How to decrypt symmetric key that was encrypted with a password

$
0
0

I run code below to create and open a symmetric key

CREATE SYMMETRIC KEY SKey1
	WITH ALGORITHM = AES_256
	ENCRYPTION BY PASSWORD ='Pa$$w0rd'
Go

OPEN SYMMETRIC KEY SKey1 DECRYPTION BY PASSWORD = 'Pa$$w0rd'

I found the KEY_ID in sys.key_encryptions is '256', so I run code below what to see what the key is, but I couldn't, why? Thanks !!

select key_id, Convert(nvarchar,  DecryptByPassPhrase(N'Pa$$w0rd', a.crypt_property))
from sys.key_encryptions a
where key_id ='256'

Get list of tables & views with no roles assigned ?

$
0
0

Hello, is there a script that can list just the tables and views within a DB that have no roles assigned?

Thanks in advance.

Using Corporate CA Issued Certificate for TDE

$
0
0

Hello,

No issues in using the Sql server issued certificate to bind to the concerned user database in SQL2k12 enterprise edition. When renewing the current certificate, wondering whether we can use the certificate issued by the corporate issuing CA server, import it using sql statement and bind it to the concerned user db? The only issue that I see is using the Issued To and Issued By will be different on the certificate.

Will greatly appreciate your input.

Thanks.

Victor


Victor

roles and permissions

$
0
0

I want to  create a user defined role to give the following access to our report developers in sql server 2008R2:

Read data and create stored procs in certain databases, certain schema(s). They should be able to execute user defined functions create and execute stored procs. What permissions do I give?

I think giving db_ddladmin would give them more then what I described above

Thanks

Viewing all 3027 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>