.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

What are the required Security permissions to call SAM accountmanagement over the wire, using System

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :.NET Framework


I need to perform remote management on the local SAM database.  I am getting a security permission error, but can't figure out what the required permissions need to be.  My test harness works great as a locally authenticated user however the permission issue gets thrown when I am trying to connect to a remote host that isn't part of the domain.

The exception is getting thrown on the call to ValidateCredentials, which is found in the constructor for the LocalAccount class below, specifically you will see it  public LocalAccount(string Server, string User, string Password)

My test environment includes windows 7 machines that are working in a offline mode trying to connect to machines running XP, 2003 and Windows 7 that are not part of the domain.

Any and all help would be appreciated.


using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;

namespace WindowsManagement
  class Program

View Complete Post

More Related Resource Links

System.Security.Permissions.SecurityPermission, mscorlib, Version=, Culture=neutral, PublicKe



I am currently working on SQL server reporting. I have created custom assemblies. I am loading the custom assebly in the rdl file.

I am getting following exception


An error occurred while executing OnInit: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (rsErrorInOnInit)



Please let me know if anyone knows the reason.

Thanks in Advance.

Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version


I am using Itext sharp to create a pdf. I am adding an image and I keep getting this error

Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

it is this bit of code that is causing this


string imagepath = "C:\\BMSApplicationFiles\\PDFImages\\bullfrogWeb.gif";

//add the Image to the DOC
  Image bullfrogImage = Image.GetInstance(imagepath);
  bullfrogImage.SetAbsolutePosition(10, doc.PageSize.Height - 36);

If i comment this out, the PDF builds and no errors are thrown (there is just no image)

I don't understand cause I am am trying to do is read a file.

The directory does have full permission granted to IISUser

Any ideas why I am still geting this permissions error?

[FtpWebRequest] System.Security.Authentication.AuthenticationException: A call to SSPI failed


Hi All,

   I'm using FtpWebReuqest, SSL enabled, to connect and upload files to an FTP server.

   During testing of the module i'm developing, I've encountered an unhandled exception indicating,

   "System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The token supplied to the function is invalid"


Now before I decided to post this question here, I've searched the net and found several posts related to this. However, most them were not really helpful and not that clear. Hence, the post. :)

Additional info, I've already over ride the validation part of the SSL connection using the codes below:


ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(MyCertValidationCb);

public static bool MyCertValidationCb(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)


        return true;



What I can't really figure out is the root caus



hello i have the following problem

i have upload my content to hosting server but i get the following error

Security Exception

Description: 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.Web.AspNetHostingPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of typ

System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPerm


Good Day all,

Having an issue with an outside user accessing my IIS7 box. I do not have this problem when running the website from my host machine. I found this post: Http://forums.asp.net/t/1371394.aspx. I assure you that this is not a solution because I am not storing any of my files on a network share. 

What do you think my approach should be. 

I already have read rights to IIS user to my BIN folder. 

Thanks for the help. 

Required permissions cannot be acquired when host asp.net 3.5 application in godaddy


I got the following error when click print report button.

Application : asp.net 3.5

Crystal report : 10.5

Host: godaddy

Please help me.


Required permissions cannot be acquired.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Windows Server 2003: Discover Improved System Info, New Kernel, Debugging, Security, and UI APIs


There's a lot to say about Windows Server 2003. First of all, it's the first operating system with built-in .NET Framework support, and it's the first 64-bit OS from Microsoft. But wait, there's more! There are lots of new features and APIs in this version as well. For instance, Windows Server 2003 features Hot Add Memory and a number of other arcane new tidbits. There are new APIs for handling threads, directories, and files, and new features like the low fragmentation heap for managing memory and system information. There's vectored exception handling and new UI APIs as well.OS internals expert Matt Pietrek takes a look at the additions he finds most interesting and useful so you'll have a good place to start when you dive into Windows Server 2003.

Matt Pietrek

MSDN Magazine June 2003

Security in .NET: The Security Infrastructure of the CLR Provides Evidence, Policy, Permissions, and


The common language runtime of the .NET Framework has its own secure execution model that isn't bound by the limitations of the operating system it's running on. In addition, unlike the old principal-based security, the CLR enforces security policy based on where code is coming from rather than who the user is. This model, called code access security, makes sense in today's environment because so much code is installed over the Internet and even a trusted user doesn't know when that code is safe.In this article, Don Box explains how code access security works in the CLR. He discusses the kinds of evidence required by policy, how permissions are granted, and how policy is enforced by the runtime.

Don Box

MSDN Magazine September 2002

System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlCli

I have created a windows library control that accesses a local sql database I tried the following strings for connecting Dim connectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true" Dim connectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI"   I am not running the webpage in a virtual directory but in C:\Inetpub\wwwroot\usercontrol and I have a simple index.html that tries to read from an sql db but throws the error System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)   at System.Security.PermissionSet.Demand()   at System.Data.Common.DbConnectionOptions.DemandPermission()   at System.Data.SqlClient.SqlConnection.PermissionDemand()   at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, etc etc  The action that failed was:DemandThe type of the first permission that failed was:System.Data.SqlClient.SqlClientPermissionThe Zone of the assembly that fa

SMO System.Security.SecurityException

Hello everybody I wrote a backup procedure using smo. this procedure works great on my dev box, but once deployed to the hosting company's web server it throws above exception ("System.Security.SecurityException: That assembly does not allow partially trusted callers.") I did some research on the subject and it seems that hosting companies give you only medium trust in the config file and hence cannot access smo. My hosting admin is a great fellow (www.alsonetworks.com, recommended!) and is willing to help out, so he told me that he: A. installed smo 2008 in the GAC B. added them to the medium.config file Even so, I still receive the error. Now, I'm pretty sure he'd do anything possible to get it to work (sans giving full trust) but i'd got to tell him what to do. So can anybody advise any additional steps that can be done to get this to work? my site is built with vb asp.net 3.5 against mssql 2008, but the hosting site uses mssql 2005. I appreciate your help and advice PS. I've also read a lot about AllowPartiallyTrustedCallers, but I understand that it is irrelevant here as i have not written the assembly. it would be something ms could/should do. is that correct?   heres the code : Public Shared Sub Backup() Dim sqlCon = New SqlConnection(ConfigurationManager.ConnectionStrings("Main").ConnectionString) Dim conn As New Server

A call to SSPI failed: The target principal name is incorrect - How to ignore this Security Check

I find that I am getting this error since I am using the netTCPBinding. I don't get this exception when the client and server are on the same machine, but when they are on different machines, this exception occurs. If I set the identity on the end point as mentioned in the article: http://blogs.msdn.com/b/drnick/archive/2007/11/08/setting-a-user-principal-on-the-endpoint.aspx it is working fine.   So my question is , should the service end point always have an identity when using netTcpBinging? I tried setting Security.Mode = None and still I got this identity exception. is there any way through which I can ask the service to ignore the SSPI details and accept client request?   Thanks!

Encryption (System.Security.Cryptography) .Net 2.0

Hi, Query regarding cryptography.  I'm using .net cryptography to encrypt and decrypt files stored on disk on an asp.net website using .Net 2.0 framework.   The code (copied below) works fine to encrypt and decrypt pdf, tif, jpg, etc.  However when it comes to MS Word documents with embedded images and/or tables I get a "Bad data" error when decrypting.   The same document saved to rtf format is encrypted and decrypted without error.  Also simple formatted text documents in Word format (Office 2003) do not throw an error when being decrypted. Would someone care to point out where I'm going wrong? Thanks, code below   _________________________________    Public Sub Encrypt(ByVal Userid As Integer, ByVal FilePath As String)        'Encrypt the file        Try            Dim EncryptedFilePath As String = FilePath & "enc"            Dim clsNetEnCrypt As New NetEncrypt(User)            clsNetEnCrypt.Encrypt(FilePath, EncryptedFilePath)            'Remove the Unencrypted file  

Copy sharepoint 2007 folder (with sub folders) with all the security permissions

I am looking to copy a common sharepoint folder(sub folders) in 2007 with all the security permissions intact, to a different location in the same site, Does anyone know how to do this?

System Admin Permissions Break when SSL is enabled

When I create a site in SharePoint 2010 Central Admin I have full permissions to grant user permissions and edit the site.  However, when I enable SSL I lose those permissions.  Any suggestions as to why this is happening?

Minimum Permissions Needed To See Cdc tables In System Tables Folder

What are the minimum permissions needed for a user to see the cdc tables in the System Tables folder in SQL Management Studio?DJ Baby Anne's Biggest Fan................

Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtec

I have a windows service that runs on client machines and connects to a WCF service on a server.  This windows service seems to work fine on Windows XP, Vista and 7  machines, but when I try and run it on a Server 2008 R2 machine I get the following error: System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for system.serviceModel/bindings: Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement' from assembly 'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (C:\Program Files (x86)\MyFolder\MyApp\MyAppWinSVC.exe.Config line 4) ---> System.TypeLoadException: Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement' from assembly 'System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.    at System.ServiceModel.Configuration.HttpTransportSecurityElement.get_Properties() I have the 3.5 sp1 feature installed. The only thing I have found online that is remotely similar is this MS hotfix: http://support.microsoft.com/kb/2262911 But when I try and apply it, it says that it isn't for my computer. Does anyone have any ideas how to resolve this issue?

System.DirectoryServices.AccountManagement: FileNotFound exception while creating PrincipalContext o

Hi, I want to create a local group for my Netapp server. And also add a domain user under this group. Using .NET namepaces System.DirectoryServices.AccountManagement, I can achive this for Windows server. But if the same code is tried on NetApp, following exception is thrown: Unhandled Exception: System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)   at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()   at System.DirectoryServices.DirectoryEntry.RefreshCache()   at System.DirectoryServices.AccountManagement.PrincipalContext.DoMachineInit()   at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()   at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()    at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)   at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, String identityValue)   at System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext context, String identityValue)   at AddGroup.Program.Main(String[] args) Does S
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend