Access Active Directory from ASP.net 2.0 application

Discussion in 'ASP .Net' started by =?Utf-8?B?S2Fp?=, Jun 1, 2007.

  1. Hi all,

    I need to access information from Active Directory from my ASP.net 2.0
    application (vb.net). Therefore I made a DLL which retrieves the data from
    Active Directory. This works fine, all tests successfull. But when I call
    this DLL from my web application (currently installed on my local SQL Server)
    I always get an error message:

    "The specified domain either does not exist or could not be contacted."

    I tested it with the same values in the DLL-Test and it works fine so it
    seems to be a problem accessing the AD from IIS? The error is thrown in this
    line:

    "If Not (dirSearcher.FindOne() Is Nothing) Then"

    Many thanks in advance!
    Kai
    =?Utf-8?B?S2Fp?=, Jun 1, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?S2Fp?=

    Mark Rae Guest

    "Kai" <> wrote in message
    news:...

    > I need to access information from Active Directory from my ASP.net 2.0
    > application (vb.net). Therefore I made a DLL which retrieves the data from
    > Active Directory. This works fine, all tests successfull. But when I call
    > this DLL from my web application (currently installed on my local SQL
    > Server)
    > I always get an error message:
    >
    > "The specified domain either does not exist or could not be contacted."
    >
    > I tested it with the same values in the DLL-Test and it works fine so it
    > seems to be a problem accessing the AD from IIS? The error is thrown in
    > this
    > line:
    >
    > "If Not (dirSearcher.FindOne() Is Nothing) Then"
    >
    > Many thanks in advance!


    The default account which ASP.NET uses does not have permission to query
    ActiveDirectory - you will need to impersonate a "standard" Domain User
    account for this:
    http://www.codeproject.com/useritems/everythingInAD.asp
    http://support.microsoft.com/kb/317012
    http://www.15seconds.com/issue/020730.htm
    http://support.microsoft.com/kb/326340


    --
    http://www.markrae.net
    Mark Rae, Jun 1, 2007
    #2
    1. Advertising

  3. Hi Mark,
    thanks for your reply. I just set impersonation to 'true' in web.config and
    it's running fine now... I wonder why there is a impersonation class on
    CodeProject.... It sounds so difficult but was really easy now. But I guess I
    should read this one at weekend as there are some information about possible
    security problems ...

    http://msdn2.microsoft.com/en-us/library/ms998351.aspx
    =?Utf-8?B?S2Fp?=, Jun 1, 2007
    #3
  4. =?Utf-8?B?S2Fp?=

    Mark Rae Guest

    "Kai" <> wrote in message
    news:...

    > thanks for your reply. I just set impersonation to 'true' in web.config
    > and
    > it's running fine now...


    Hurrah!

    > I wonder why there is a impersonation class on CodeProject....


    As an example of another way of doing things, I suppose - the .NET Framework
    is so feature-rich that there is (almost) always more than one way of doing
    anything...

    > It sounds so difficult but was really easy now. But I guess I
    > should read this one at weekend as there are some information about
    > possible
    > security problems ...
    >
    > http://msdn2.microsoft.com/en-us/library/ms998351.aspx


    Also, you might like to have a look in microsoft.public.adsi.general -
    anything that Joe Kaplan says, you can take as gospel... :)


    --
    http://www.markrae.net
    Mark Rae, Jun 1, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page