Paulson Maclean
Paulson Maclean

Reputation: 1

Request for permission of type System.DirectoryServices failed

Getting issue like

Request for permission of type "System.DirectoryServices.. 4.0.0.0' failed

while running a web application from VS IDE in a server owned by our team when LDAP code gets executed. Similarly, when oracle connection initialisation code is called, System.Security.Permission error is occurring. Target framework version is .NET 4.5

Tried setting trust level to Full and without it as well in app web.config. AllowOverride is set to true only in web.config under respective .NET framework's Config folder. I need proper steps to troubleshoot the root cause of these issues.

Upvotes: -1

Views: 67

Answers (1)

Walter Verhoeven
Walter Verhoeven

Reputation: 4421

Your code doesn't run with sufficient permissions. Update the user that is used in hosting your web application and have it have the right to do this.

As per comment this doesn't work for web applications Add a Manifest file and set the app to be admin mode:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
            </requestedPrivileges>
        </security>
    </trustInfo>
</assembly>

Upvotes: -1

Related Questions