DirectorySearcher

Discussion in 'ASP .Net' started by =?Utf-8?B?TGFtaXM=?=, Aug 28, 2007.

  1. Hi,
    I have this code sample in my window application project :
    DirectorySearcher mySearcher = new DirectorySearcher("(CN=WMLIN2)");
    foreach( SearchResult resEnt in mySearcher.FindAll()) and it works
    perfectly, it connecst to the domain and FindAll() function excutes perfectly
    without any troubles.

    I need run the same code in my ASP .Net web application and this wouldn't
    work. FindAll() gives an exception that i can not connect to the domain or
    might not exist. Any ideas why it works in wondows appl. but not asp.net. Any
    ideas how to fix that?
    --
    LZ
    =?Utf-8?B?TGFtaXM=?=, Aug 28, 2007
    #1
    1. Advertising

  2. "Lamis" <> wrote in message
    news:...

    > I have this code sample in my window application project :
    > DirectorySearcher mySearcher = new DirectorySearcher("(CN=WMLIN2)");
    > foreach( SearchResult resEnt in mySearcher.FindAll()) and it works
    > perfectly, it connecst to the domain and FindAll() function excutes
    > perfectly
    > without any troubles.
    >
    > I need run the same code in my ASP .Net web application and this wouldn't
    > work. FindAll() gives an exception that i can not connect to the domain or
    > might not exist. Any ideas why it works in wondows appl. but not asp.net.


    Because the standard account under which ASP.NET runs does not (normally)
    have sufficient privileges to query ActiveDirectory.

    > Any ideas how to fix that?


    Two ways:

    1) Use impersonation so that your web app runs under a different user
    account which has access to Active Directory (recommended)

    2) Supply explicit credentials to the DirectoryEntry constructor in the
    System.DirectoryServices namespace


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Aug 28, 2007
    #2
    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.
Similar Threads
  1. cameron

    DirectorySearcher & sorting

    cameron, Jul 4, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    4,752
    Yan-Hong Huang[MSFT]
    Jul 7, 2003
  2. dave
    Replies:
    0
    Views:
    768
  3. Jay
    Replies:
    1
    Views:
    19,259
  4. =?Utf-8?B?QW5kcmV3MTI0?=

    DirectorySearcher.FindAll()

    =?Utf-8?B?QW5kcmV3MTI0?=, Jul 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,321
    =?Utf-8?B?QW5kcmV3MTI0?=
    Jul 11, 2004
  5. Roger Bavaud

    DirectorySearcher Filter Exchange Server

    Roger Bavaud, Nov 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    606
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 5, 2004
Loading...

Share This Page