all groups > sql server programming > april 2006 >
You're in the

sql server programming

group:

How do I: Create UNSAFE Assembly in SQL 2005


How do I: Create UNSAFE Assembly in SQL 2005 Russell Mangel
4/9/2006 10:50:57 PM
sql server programming:
I am trying to get a VS2005 C# assembly created for SQL Server 2005, I am
unable to do so because of the security errors.

My Question:
How do I register and UNSAFE assembly? I would like to be able to create new
Assemblies without using the impossibly complicated strong certificate
signing.

I have enabled the database with SET TRUSTWORTHY ON . But I am unable to
figure out how to add the UNSAFE ASSEMBLY permission to the database owner.
Where do I set this?

I would really like to disable these security checks for the entire SQL
Server, if possible.

// Environment.MachineName is what needs more security.
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString GetMachineName()
{
SqlString s = Environment.MachineName;
return s;
}
}

// The Error message when I try to deploy the project from VS2005 C# Project
Error 1 CREATE ASSEMBLY for assembly 'SqlServerProject1' failed because
assembly 'SqlServerProject1' is not authorized for PERMISSION_SET = UNSAFE.
The assembly is authorized when either of the following is true: the
database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the
TRUSTWORTHY database property on; or the assembly is signed with a
certificate or an asymmetric key that has a corresponding login with UNSAFE
ASSEMBLY permission. SqlServerProject1

Re: How do I: Create UNSAFE Assembly in SQL 2005 Russell Mangel
4/9/2006 11:27:27 PM
The Link doesn't work...

[quoted text, click to view]

Re: How do I: Create UNSAFE Assembly in SQL 2005 SriSamp
4/10/2006 12:00:00 AM
The link is inside SQL Server 2005 books online which you would have
installed. You can paste it in the address bar in the BOL.
--
HTH,
SriSamp
Email: srisamp@gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp

[quoted text, click to view]

Re: How do I: Create UNSAFE Assembly in SQL 2005 SriSamp
4/10/2006 12:00:00 AM
This help topic in BOL should help you out:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/denet9/html/a2bc503d-b6b2-4963-8beb-c11c323f18e0.htm.
--
HTH,
SriSamp
Email: srisamp@gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp

[quoted text, click to view]

Re: How do I: Create UNSAFE Assembly in SQL 2005 Niels Berglund
4/10/2006 1:59:21 AM
"Russell Mangel" <russell@tymer.net> wrote in
news:#WtP#KGXGHA.3848@TK2MSFTNGP05.phx.gbl:

[quoted text, click to view]

From master you run:

GRANT UNSAFE ASSEMBLY TO [db_owner]

where db_owner is the login of the owner of the database where you want
to create the assembly.

Niels

--
**************************************************
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb at develop dot com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
Re: How do I: Create UNSAFE Assembly in SQL 2005 Russell Mangel
4/10/2006 4:53:30 AM
[quoted text, click to view]

Thanks!

Working now.

Russell Mangel
Las Vegas, NV

AddThis Social Bookmark Button