How to get LDAP directory server

Discussion in 'ASP .Net Security' started by VK, May 26, 2005.

  1. VK

    VK Guest

    Hello,

    We have installed AD and now I want to authenticate the user against AD via
    IIS and get the user information via LDAP. However I dont know the LDAP
    Directory. How do I get the LDAP directory?

    Thanks
    VK, May 26, 2005
    #1
    1. Advertising

  2. VK schrieb:

    > We have installed AD and now I want to authenticate the user against AD via
    > IIS and get the user information via LDAP. However I dont know the LDAP
    > Directory. How do I get the LDAP directory?


    You can use this function:

    Function GetADsDomainName as String
    dim objRootDSE
    objRootDSE = GetObject("LDAP://rootDSE")
    return objRootDSE.Get("DefaultNamingContext")
    End Function

    It returns the LDAP-path of your ActiveDirectory:

    For Example "dc=yourdomain,dc=com".

    Jan
    Jan Peter Stotz, May 27, 2005
    #2
    1. Advertising

  3. VK

    VK Guest

    I tried that and get:

    Cannot create ActiveX component.

    Private Function GetLDAPEntry() As DirectoryEntry
    Dim objRootDSE
    objRootDSE = GetObject("LDAP://rootDSE") <-- Error here
    Return New
    DirectoryEntry(objRootDSE.Get("DefaultNamingContext")) End Function



    "Jan Peter Stotz" wrote:

    > VK schrieb:
    >
    > > We have installed AD and now I want to authenticate the user against AD via
    > > IIS and get the user information via LDAP. However I dont know the LDAP
    > > Directory. How do I get the LDAP directory?

    >
    > You can use this function:
    >
    > Function GetADsDomainName as String
    > dim objRootDSE
    > objRootDSE = GetObject("LDAP://rootDSE")
    > return objRootDSE.Get("DefaultNamingContext")
    > End Function
    >
    > It returns the LDAP-path of your ActiveDirectory:
    >
    > For Example "dc=yourdomain,dc=com".
    >
    > Jan
    >
    VK, May 27, 2005
    #3
  4. In an ASP.NET application, you may need to supply a domain name in your
    binding string and some valid credentials in the username and password
    parameters. The issue is that in ASP.NET, it is often the case that you are
    running under a local machine account whose credentials cannot be used to
    access AD directly.

    Essentially, what you will want to do is read the Context.User.Identity.Name
    property in ASP.NET to get the current user name (will be domain\username),
    then pull off the username part and use that in a search filter to search
    the domain for that user. The filter would look like
    (sAMAccountName=username)

    Using PropertiesToLoad on the DirectorySearcher, you can specify which AD
    attributes you wish to retrieve and get them back in a SearchResult object.

    Depending on the structure of your AD, you may want to search at the domain
    level or do a global catalog search at the forest level
    (GC://domain.com/xxxxx), depending on whether multiple domains are involved.

    HTH,

    Joe K.

    "VK" <> wrote in message
    news:...
    >I tried that and get:
    >
    > Cannot create ActiveX component.
    >
    > Private Function GetLDAPEntry() As DirectoryEntry
    > Dim objRootDSE
    > objRootDSE = GetObject("LDAP://rootDSE") <-- Error here
    > Return New
    > DirectoryEntry(objRootDSE.Get("DefaultNamingContext")) End Function
    >
    >
    >
    > "Jan Peter Stotz" wrote:
    >
    >> VK schrieb:
    >>
    >> > We have installed AD and now I want to authenticate the user against AD
    >> > via
    >> > IIS and get the user information via LDAP. However I dont know the LDAP
    >> > Directory. How do I get the LDAP directory?

    >>
    >> You can use this function:
    >>
    >> Function GetADsDomainName as String
    >> dim objRootDSE
    >> objRootDSE = GetObject("LDAP://rootDSE")
    >> return objRootDSE.Get("DefaultNamingContext")
    >> End Function
    >>
    >> It returns the LDAP-path of your ActiveDirectory:
    >>
    >> For Example "dc=yourdomain,dc=com".
    >>
    >> Jan
    >>
    Joe Kaplan \(MVP - ADSI\), May 27, 2005
    #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.
Similar Threads
  1. Replies:
    1
    Views:
    514
    Raymond DeCampo
    Feb 21, 2006
  2. rcmn
    Replies:
    1
    Views:
    327
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Nov 6, 2006
  3. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
    Replies:
    5
    Views:
    228
  4. Ian Macdonald
    Replies:
    0
    Views:
    206
    Ian Macdonald
    Mar 15, 2005
  5. James Hughes
    Replies:
    4
    Views:
    312
    James Hughes
    Dec 13, 2005
Loading...

Share This Page