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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -