Link to home
Start Free TrialLog in
Avatar of jgags
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.  
ASKER CERTIFIED SOLUTION
Avatar of hybridron
hybridron

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jgags
jgags

ASKER

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.