Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

calling ADSI objects from Web Application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
johnny - 28 Jan 2005 09:15 GMT
Hello, I got this weird problem. I have an intranet application that needs to
communicate with Active directory. Authentication to Web application is done
by means of active directory accounts.

Now I have this code:

DirectoryEntry objDomain = new DirectoryEntry("LDAP://rootDse");
string domain = objDomain.Properties["defaultNamingContext"].Value.ToString();
DirectorySearcher ds = new DirectorySearcher();
ds.SearchRoot = new DirectoryEntry(string.Format("LDAP://{0}",domain));
ds.Filter = "(&(objectClass=group)(sAMAccountName=group_name))";
ds.SearchScope = SearchScope.Subtree;
SearchResult res = ds.FindOne();

When I run the application from any computer and authenticate as a user with
domain administrator privilige, everything works fine. When I authenticate as
a normal user application fail at line
SearchResult res = ds.FindOne();
throwing this exception:

Text: An operations error occurred
Exception Details: System.Runtime.InteropServices.COMException: An
operations error occurred
Stack Trace:
  System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +513
  System.DirectoryServices.DirectoryEntry.Bind() +10
  System.DirectoryServices.DirectoryEntry.get_AdsObject() +10
  System.DirectoryServices.DirectorySearcher.FindAll(Boolean
findMoreThanOne) +198
  System.DirectoryServices.DirectorySearcher.FindOne() +31

To remind: This bunch of code is called from a library that is inside GAC to
assert it's not consindered as partially trusted code.

I have no idea, where the problem could be. As a first thing I thought the
user doesn't have a privilige to communicate to AD, so I took this piece of
code and put it into a Windows application and run as a normal user. It
worked ok.

Can anybody have any idea what I should do? I'd be very grateful. Thanks in
advance.
James Winters - 28 Jan 2005 11:09 GMT
[snip]
> When I run the application from any computer and authenticate as a user
> with
[quoted text clipped - 3 lines]
> SearchResult res = ds.FindOne();
> throwing this exception:

[snip]
> Can anybody have any idea what I should do? I'd be very grateful. Thanks
> in
> advance.

When you run a web app the app will propagate as either ASPNET or NETWORK
SERVICE as default (depending on IIS version).

To change this behaviour you need to switch on impersonation in web.config.

--
James

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.