Question : Request for the permission of type 'Microsoft.SharePoint.Secu<wbr />rity.Share<wbr />PointPermi<wbr />ssion, Microsoft.SharePoint.Secur<wbr />ity, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e<wbr />9429c' fail

So I created a simple web service to create a directory if one did not exists in a sharepoint library.  The web service build went fine and I published it and was able to pull it into my VB.NET application with a problem.  When I try to run the application on the remote machine I get the following Error:

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

Here the class I created on the remote worksation that points to the web service:

    Public Function MakeDirectory(ByVal Library As String, ByVal ObjectID As String) As String
        Dim objKFGMOSS_Directory As New KFGMOSS_DirectoryServices.Service
        Dim MyURL As String

        'Pass Authentication
        objKFGMOSS_Directory.PreAuthenticate = True
        objKFGMOSS_Directory.Credentials = System.Net.CredentialCache.DefaultCredentials
        MyURL = objKFGMOSS_Directory.MakeDirectory(Library, ObjectID)
        objKFGMOSS_Directory.Dispose()

        Return MyURL
    End Function

How to I resolve this error?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
------ Web Service Code ---------
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports Microsoft.SharePoint
 
 _
 _
 _
Public Class Service
     Inherits System.Web.Services.WebService
 
     _
    Public Function MakeDirectory(ByVal Library As String, ByVal ObjectID As String) As String
        'Check to see if a directory exists if not create it under the library passed
        Dim MyServer As New SPSite(Library)
        Dim MyWeb As SPWeb
        Dim MyFolder As SPFolder
 
        'Open the Sharepoint Web
        MyWeb = MyServer.OpenWeb
        MyWeb.AllowUnsafeUpdates = True
        MyFolder = MyWeb.GetFolder("Documents")
        Try
            MyFolder = MyWeb.GetFolder(ObjectID)
 
        Catch ex As Exception
            MyWeb.Folders.Add(ObjectID)
 
        End Try
 
        'Return the URL
        Return MyWeb.GetFolder("Documents/" & ObjectID).Url
    End Function
 
End Class

Answer : Request for the permission of type 'Microsoft.SharePoint.Secu<wbr />rity.Share<wbr />PointPermi<wbr />ssion, Microsoft.SharePoint.Secur<wbr />ity, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e<wbr />9429c' fail

It sounds like your issue is with your class not being trusted by IIS.  You can do one of three things:

1) set Full trust in the Web.config file ()
2) install dll to GAC
3) create a custom trust policy file

see here:
http://www.sharepointblogs.com/ssa/archive/2007/01/12/moss-2007-and-code-access-security.aspx
Random Solutions  
 
programming4us programming4us