Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find the asymmetric key -- because it does not exist or you do not have permission

I am trying to be able to run a .Net dll through SQL using the CLR - I am doing so unsuccessfully.

I am following the instructions here

So I am doing the following:

CREATE ASYMMETRIC KEY AKEY_SqlClr FROM EXECUTABLE FILE = 'C:\dlls\mySqlClr.dll'

Which works fine and creates the Key, then I try to do the following:

CREATE LOGIN SQLCLR_AsymKeyLogin FROM ASYMMETRIC KEY AKEY_SqlClr

And I get the error:

Cannot find the asymmetric key 'AKEY_SqlClr', because it does not exist or you do not have permission.

How could I not have permissions to this? I have verified that I have CREATE LOGIN permissions. Any ideas?

like image 578
naspinski Avatar asked Sep 21 '11 16:09

naspinski


Video Answer


1 Answers

Logins are server principals and as such they cannot be created from keys stored in user databases. You must create the key from assembly in master database:

use master;
CREATE ASYMMETRIC KEY AKEY_SqlClr FROM EXECUTABLE FILE = 'C:\dlls\mySqlClr.dll';
CREATE LOGIN SQLCLR_AsymKeyLogin FROM ASYMMETRIC KEY AKEY_SqlClr;
like image 72
Remus Rusanu Avatar answered Sep 19 '22 18:09

Remus Rusanu