Step Bi Step
Posts Tagged Trust Level
The application attempted to perform an operation not allowed by the security policy – DirectoryServices
Posted by Rajanihanth in Active Directory, DirectoryServices, SharePoint 2007 on March 23, 2012
I have developed a custom search and successfully deployed in our SharePoint 2007 (We have almost 16 sites and one document library, so we decided to filter the search according to the location, I will post the step by step development to the custom search later :)). My manager asked me to pick the location (ie. Organizational Unit (OU)) from Active Directory (AD) according to the user dynamically and I have written a method to pick the OU, you can see the post here. So far I didn’t get any problem but when I tried to deploy the web part to the SharePoint, I have got several errors and I managed to solve them but the following error gave me very hard time.
Security Exception: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.DirectoryServices.DirectoryServicesPermission, System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ failed.
Source Error:
Stack Trace:
I tried several solutions to fix this issue but no luck, because my C# code is trying to access the AD information which is in the different server, so there is no trusted permission from SharePoint, but I could access the details form the local machine. Finally I just read the error message carefully and modified the Trust Level in the SharePoint web.config to “Full” then it was working.
Please note: Changing this Trust Level might harm your SharePoint Security!
To do the changes:
Step1: Open the web.config file (Using Notepad OR Visual Studio)
Step2: Locate the <trust level=”WSS_Minimal” originUrl=”” /> tag in the web. config file. The default value is “WSS_Minimal”. I tried “WSS_Medium” but it didn’t solve the problem, sometimes it will solve yours.
Step3: Change the <trust level=”Full” originUrl=”” />
That’s all, it is working now. Happy coding n SharePointing! There are some other solutions for this related issue, you can try.
1. Changes on the .NET Framework 2.0 Configuration tool, Tim Huffam’s blog will show how to do the work around.
References:
1. http://support.microsoft.com/kb/555466
3. http://geekswithblogs.net/timh/archive/2006/03/08/71714.aspx
Active Directory, DirectoryServices, DirectoryServicesPermission, Organizational Unit, SecurityException, SharePoint 2007, Trust Level, WSS_Medium, WSS_Minimal
Recent Posts
- TF255507: The security identifier (SID) for the following SQL Server login conflicts with a specified domain or workgroup account
- Installing Visual Studio Team Foundation Server 2010-Basic Configuration Step By Step
- The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.
- 2012 in Review!
- Getting started with Windows 8 Metro Style Application using C# – Visual Studio 2012
Categories
- .Net (23)
- Active Directory (4)
- ASP.Net (1)
- BDC (5)
- C# (5)
- Client Object model (3)
- Crystal Reports (1)
- DirectoryServices (3)
- Excel Services (3)
- GAC (1)
- InfoPath 2007 (5)
- InfoPath 2010 (4)
- MetaData (1)
- SharePoint 2007 (19)
- SharePoint 2010 (10)
- Silverlight (2)
- SQL Server (9)
- SSRS (3)
- STSADM (2)
- Tech Tips-.Net (4)
- Tech Tips-SharePoint (1)
- Tech Tips-SQL (2)
- TFS (3)
- TFS 2010 (3)
- TFS 2012 (1)
- Uncategorized (1)
- VB.Net (1)
- Versus (vs) (2)
- Visual Studio 2012 (3)
- VSTA (3)
- Webpart (8)
- Windows 8 (3)
- WSP Builder (4)
- XAML (1)
Certifications
Labels
.Net Active Directory BDC C# Client Object model Crystal Reports DirectoryServices Excel Services GAC InfoPath 2007 InfoPath 2010 MetaData SharePoint 2007 SharePoint 2010 Silverlight SQL Server SSRS STSADM Tech Tips-.Net Tech Tips-SharePoint Tech Tips-SQL TFS TFS 2010 Uncategorized Versus (vs) Visual Studio 2012 VSTA Webpart Windows 8 WSP BuilderCalendar
April 2023 M T W T F S S 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