Tiszteletem!
.NET 2.0-ában készítettem egy tárolt eljárást SQL 2005-höz. Az eljárás funkciója semmi különös: külső url-ről letöltött tartalmat ad vissza. Híváskor a Management Studioban azonban ezt a hibát adja vissza:
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Az eljárás kódja VB-ben a következő:
Code Block
Imports System
Imports System.IO
Imports System.Net
Imports System.Security
Imports System.Security.Permissions
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlTypes
Imports Microsoft.SqlServer.Server
Public Class StoredProcedures <Microsoft.SqlServer.Server.SqlProcedure> _
Public Shared Sub ReadUrl(Url As SqlString)
Dim pWeb As System.Net.WebPermission = New WebPermission(NetworkAccess.Connect, Url)
Dim pSec As System.Security.Permissions.SecurityPermission = New SecurityPermission(SecurityPermissionFlag.AllFlags)
pWeb.Assert()
pSec.Assert()
Dim myWebClient As New WebClient()
Dim myStream As Stream = myWebClient.OpenRead(Url)
Dim sr As New StreamReader(myStream)
SqlContext.Pipe.Send(sr.ReadToEnd())
myStream.Close()
End Sub
End Class
A szerelvényt és a tárolt eljárást a szokásos módon (CREATE ASSEMBLY ... permission_set = SAFE) regisztráltam. A "Hello World!" eljárás működik, azonban ez nem. Gondolom, hogy a webes dolog miatt, de nem jövök rá, hogy mi lehet a baj. A .NET Franework 2.0 Configuration-ben már állítgattam a dolgokat (Full Trust meg ilyesmi), de az sem segített.
A szerelvény kaptt erős nevet (sp -k MyKey.snk) is meg beregisztráltam a GAC-ba is, de mindíg ugyanaz a hiba.
A permission_set-et nem tudom UNSAFE-re vagy EXTERNAL_ACCESS-re állítani pedig a feltételek teljesülnek hozzá.
Ennek hibaüzenete:
CREATE ASSEMBLY for assembly 'My' failed because assembly 'My' is not authorized for PERMISSION_SET = EXTERNAL_ACCESS. The assembly is authorized when either of the following is true: the database owner (DBO) has EXTERNAL ACCESS 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 EXTERNAL ACCESS ASSEMBLY permission. If you have restored or attached this database, make sure the database owner is mapped to the correct login on this server. If not, use sp_changedbowner to fix the problem.
Kérem segítsenek, hogy mit kell tenni ilyen esetben.
Köszönöm!