c# - Can't access directory services from server - DirectoryServicesCOMException -


i'm trying query ad in asp.net (4.0) application running on windows server 2008 r2 (iis7 installed). in runs fine on local computer (windows 7), not on server. i'm trying userid of current user. i've looked @ q&a of similar question, no success.

here's code snip...

public partial class default : system.web.ui.page     {         principalcontext principalctx = new principalcontext(contexttype.domain);         userprincipal currentuser = userprincipal.current; 

the web.config has

<authentication mode="windows"/> <identity impersonate="true" /> 

and here's error & stack trace...

[directoryservicescomexception (0x80072020): operations error occurred. ]    system.directoryservices.directoryentry.bind(boolean throwiffail) +781    system.directoryservices.directoryentry.bind() +44    system.directoryservices.directoryentry.get_adsobject() +42    system.directoryservices.propertyvaluecollection.populatelist() +29    system.directoryservices.propertyvaluecollection..ctor(directoryentry entry, string propertyname) +119    system.directoryservices.propertycollection.get_item(string propertyname) +163    system.directoryservices.accountmanagement.principalcontext.doldapdirectoryinitnocontainer() +541617    system.directoryservices.accountmanagement.principalcontext.dodomaininit() +51    system.directoryservices.accountmanagement.principalcontext.initialize() +141    system.directoryservices.accountmanagement.principalcontext.get_queryctx() +42    system.directoryservices.accountmanagement.principal.findbyidentitywithtypehelper(principalcontext context, type principaltype, nullable`1 identitytype, string identityvalue, datetime refdate) +27    system.directoryservices.accountmanagement.principal.findbyidentitywithtype(principalcontext context, type principaltype, identitytype identitytype, string identityvalue) +146    system.directoryservices.accountmanagement.userprincipal.findbyidentity(principalcontext context, identitytype identitytype, string identityvalue) +44    system.directoryservices.accountmanagement.userprincipal.get_current() +390 

i've tried running iis application pool networkservice , applicationpoolidentity , no good.

any ideas? thanks.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -