Active Directory, LDAP and Forms Authentication Problem

Discussion in 'ASP .Net Security' started by Ken Dourado, Nov 10, 2003.

  1. Ken Dourado

    Ken Dourado Guest

    Hi,

    I've got an intranet ASP.NET application that uses Forms Authentication.
    What I'd like to do is get the username (in the format name.surname) of
    the visitor and then retrieve their Display Name from Active Directory
    using the following method:

    internal static string GetUserDisplayName(string id)
    {
    string html = "";
    DirectoryEntry objDomain = new DirectoryEntry("LDAP://DOMAINNAME");
    DirectorySearcher objSearcher = new DirectorySearcher(objDomain);
    objSearcher.Filter = ("(objectClass=user)(sn=" + id ")");
    foreach(SearchResult sr in objSearcher.FindAll()) // this line errors
    {
    DirectoryEntry de = sr.GetDirectoryEntry();
    html = de.Properties["DisplayName"].Value.ToString() + "<br>";
    }
    return html;
    }

    I keep getting the following error message:
    System.Runtime.InteropServices.COMException: The directory service is
    unavailable

    I'm a newbie at this so I don't really understand where I'm going wrong
    or if I have to set anything up before carrying on.

    Thanks in advance for any help.

    Regards,

    Ken.


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Ken Dourado, Nov 10, 2003
    #1
    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. Tdar
    Replies:
    2
    Views:
    8,953
    Arnel
    Oct 11, 2005
  2. P Webster
    Replies:
    2
    Views:
    11,109
    P Webster
    Mar 25, 2006
  3. Tdar
    Replies:
    1
    Views:
    208
    Steven Cheng[MSFT]
    Sep 30, 2005
  4. Thana
    Replies:
    2
    Views:
    232
    Patrick.O.Ige
    Oct 3, 2006
  5. hharry

    active directory authentication using ldap

    hharry, Nov 9, 2007, in forum: ASP .Net Security
    Replies:
    1
    Views:
    245
    Joe Kaplan
    Nov 9, 2007
Loading...

Share This Page