Avatar of jgags
 asked on

DirectoryEntry causing error in Sharepoint web part

I'm trying to create a sharepoint web part (in vb.net) to access some AD attributes.    My function works fine in a windows app, but I get an "System.Security.SecurityException: Security error."   error when I place it in my sharepoint site.  Here's the description of the error:

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.

The line that it actually errors out on is where I declare an directory entry:  

Dim odomain  As DirectoryEntry = New DirectoryEntry("LDAP://" & sDomain, sUsername, sPassword)

I have the trust leve in my web config file as wss_medium.  
Any help with this issue would be greatly appreciated since I'm really out of troubleshooting options.  
Web Development

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

To be honest, I'm not exactly sure how to do that.  However, I realized that you cannot use the directoryservices namespace for a sharepoint web part unless you change the trust level in the web config file to "full".  It worked fine after I changed the trust level.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck