Re: Again! Help! I can't connect to Active Directory!

From: Anna Koloskova (Koloskova_at_discussions.microsoft.com)
Date: 11/23/04


Date: Tue, 23 Nov 2004 03:49:01 -0800

Willy, thanks a milliion for this!
The new thread was indeed working under local ASPNET account.
Explicit login and password in DirectoryEntry object did not work for me,
but I've passed System.Security.Principal.WindowsIdentity.GetCurrent() from
the calling process and impersonated it before doing directory search.
Thanks again
Anna

"Willy Denoyette [MVP]" wrote:

> You should bind using explicit credentials when using this from asp.net.
>
> 1. Supply explicit credentials
> dirEntry = new DirectoryEntry("LDAP://......",
> "account@domain", "pwd", AuthenticationTypes.Secure));
>
> 2. Use the above dirEntry object in DirectorySearcher overload in your
> asynchronous delegate procedure.
> DirectorySearcher mySearcher = new DirectorySearcher(dirEntr, ...);
>
> You have to make sure both DirectoryEntry and DirectorySearcher are using
> the same connection. If you don't pay attention to this you will end with
> two connections using different credentials. The reason for this is that
> both run on separate threads, in your case, one is impersonating while the
> other runs with the default process identity, with as result two different
> connections with different access tokens.
>
> Willy.
>
> "Anna Koloskova" <koloskova@hotmail.com> wrote in message
> news:2c04d3d2.0411221011.5289a7c@posting.google.com...
> > Hi,
> > I'm referring to the question of Amadelle (13 october 2004), please
> > see
> >
> > http://groups.google.com/groups?q=Directorysearcher+async&hl=en&lr=&c2coff=1&selm=10mrg65nb7gnb89%40corp.supernews.com&rnum=1
> >
> > kindly answered by Jared, specifically to the words
> > ---------------------------------------------------------------------
> > "If you are able to bind, but when you try to view/retrieve the
> > properties, I
> > have found that when you try to perform operations asynchronously you
> > receive the comexception."
> > ---------------------------------------------------------------------
> > I am trying to do directory search asynchronously in ASP.Net
> > application, e.g. using begininvoke to call the function that uses
> > DirectorySearcher. I am getting COM exception "The specified domain
> > either does not exist or could not be contacted".
> > The same code called not from async call works ok.
> > Can you shed any light on this behavior? Im completely lost.
> > Thank you
> > Anna
>
>
>



Relevant Pages

  • Re: How to get domainusername (NT account) from a DirectoryEntry object of user?
    ... Call LogonUser with the the userPrincipalName of the user (easily available ... > I have DirectoryEntry object for a user (using the LDAP provider and ... > to export a wrapper on top of activeds.dll and use the name translate COM ...
    (microsoft.public.dotnet.security)
  • DirectoryEntry Pooling...
    ... some data from Sun One Directories. ... Which kind of pooling do I need to use (connection pooling / object ... Is there any way to pool the directoryentry object. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: List groups that a user belong using AD
    ... If you are using AD you can use the System.DirectoryServices namspace to ... It is comprised of two classes DirectoryEntry and ... information by passing it a DirectoryEntry object. ...
    (microsoft.public.dotnet.languages.csharp)