CLR trigger – External access

By default when you create a CLR trigger, VS 2008 will deploy it as a SAFE trigger:

CREATE ASSEMBLY HelloWorld

FROM @SamplesPath + ‘HelloWorld\CS\HelloWorld\bin\debug\HelloWorld.dll’

WITH PERMISSION_SET = SAFE;

 

This is good, you always want to start with the minimal permissions but as in my previous example, when you want to work with the file system you’ll need the “external access” permission for your assembly.

The good news is that in the project properties you can set this very easy:

image

 

But the database server won’t accept this so easily. You’ll need to set the database in the Thrustworthy state.

It cost me a bit of searching but the way to do this is:

Use Master

alter database XYZ set trustworthy on

 

And now you can play.

Security warning: This setting is good for development, but in production circumstances you’ll need some other tricks. Next post when I have solved this problem!

Advertisement

About Gaston

MCT, MCSD, MCDBA, MCSE, MS Specialist
This entry was posted in Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s