473,509 Members | 3,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PERMISSION_SET = UNSAFE why?

I'm trying to write a Stored Procedure CLR for SQL Server 2005 to get some
disk information. I have this code working although the assemble has to be
create with "PERMISSION_SET = UNSAFE". Why do I have to create the assembly
with UNSAFE permissions. What can I do to make the PERMISSION_SET =
EXTERNAL_ACCESS.
Jul 19 '07 #1
1 4718
"Greg Larsen" <gr*********@removeit.msn.comwrote in message
news:2F**********************************@microsof t.com...
I'm trying to write a Stored Procedure CLR for SQL Server 2005 to get some
disk information. I have this code working although the assemble has to
be
create with "PERMISSION_SET = UNSAFE". Why do I have to create the
assembly
with UNSAFE permissions. What can I do to make the PERMISSION_SET =
EXTERNAL_ACCESS.
The permissions granted by EXTERNAL_ACCESS are as follows:

EnvironmentPermission Unrestricted --
FileIOPermission Unrestricted --
RegistryPermission Restricted Read only access to HKEY_CLASSES_ROOT,
HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, HKEY_CURRENT_CONFIG, and HKEY_USERS
SecurityPermission Restricted Assertion, Execution, SerializationFormatter,
ControlPrincipal
KeyContainerPermission Unrestricted --
SqlClientPermission Unrestricted --
EventLogPermission Restricted Only on local machine, by Administrators only
DnsPermission Unrestricted --
SocketPermission Restricted IP address only
WebPermission Restricted Access local host only via HTTP
SmtpPermission Restricted Connect access only
NetworkInformationPermission Restricted Ping access only
DistributedTransactionPermission Unrestricted --
StorePermission Unrestricted --
As you can see, you get Unrestricted FileIOPermission, so if the operations
that you mean when you mention "get some disk information" can be done via
standard File IO, you should be able to do it with PERMISSION_SET =
EXTERNAL_ACCESS.
However, if you are doing something that is not included in the preceding
table, such as using p/Invoke to call into the Windows API, then you will
need to register it as UNSAFE. If you don't want to do this, I imagine that
you could (I haven't tried it) encapsulate your functionality in a different
assembly that does an Assert for the needed permission and is installed into
the GAC, and then call this assembly from the one that you registered in sql
server.

Jul 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1895
by: Elidel | last post by:
Is the use of a COM object in a c# program considered 'unsafe' code ? Does the method that calls the COM object need the 'unsafe' keyword ? Is code that calls a COM object considered unmanaged?...
3
3143
by: Andre | last post by:
if I have an unsafe method that takes in two arrays, performs some operations and returns; I know that the garbage collector will not collect objects allocated inside the unsafe method. However, if...
8
5412
by: | last post by:
Wel, I am rebuilding the VC# 2002 project that I have deployment problems with the 2003 version, hoping this solves the problems, but now I encounter this wierd bug??? If I have the project, and...
4
609
by: Jon Milner | last post by:
How do I declare that my code is unsafe? Sorry the help files at my University have not been installed!
17
1852
by: Bradley1234 | last post by:
Sorry if this is obvious, but Ill ask... Is there a new way of using pointer operations in C# ? Ive got a Deitel book on C# that neither mentions the word "pointer" nor "unsafe" in the index....
4
4307
by: CodeTyro | last post by:
My native language being C++, I've got a few questions that a couple of hours of searching on msdn didn't answer. First, when using unsafe code and pointers, what is the C# equivalent to the C++...
1
1630
by: Z | last post by:
Hello, In my C# program I have a function that uses pointers. Is there a way to tell the compiler to compile only this function with the unsafe switch and compile the remaining project as safe...
2
3374
by: NickP | last post by:
Hi there, I am currently moving my API declarations into relevant classes for Safe and Unsafe methods. My understanding is that unsafe methods are ones that require elevated security...
0
1244
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I have two piece of unsafe code. In the first one I'm getting the byte* pointer of a Bitmap data, and the second one in inside a loop that uses that byte* pointer to set the data in the Bitmap. ...
0
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.