Tell a friend
Link to us
Bookmark Us
Total Members
      Members: 87081
Sitemap Forum Chat
 
ASP.NET Home
ASP.NET Members (3091)
ASP.NET Member Articles ( 15 )
ASP.NET Discussion (13)
ASP.NET Q & A ( 116 )
- ASP.NET Ask Question
- ASP.NET Questions
- ASP.NET Unanswered Questions
ASP.NET Resources
ASP.NET Source Code (388)
ASP.NET Articles (514)
ASP.NET Blogs (2592)
ASP.NET Jobs (0)
ASP.NET Components (207)
ASP.NET Books (8)
ASP.NET Websites (21)
ASP.NET News (106)

 
Resource Directory
ASP.NET Hosting (0)
Books & Media (0)
Community (0)
Components & Controls (0)
Other ASP.NET sites (0)
References (0)
Software & Server (0)
Source Code (0)
Tutorials (0)
Web Applications (0)

 
GROUP INFO
Members: 3091
Access Type: Anyone can join

 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
LINQ Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Javascript Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Grails Tutorial
Hibernate Tutorial
Java 1.6 Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Service-Oriented Architecture (SOA) Tutorial For Managers
Spring Tutorial
Struts Tutorial
Tomcat Tutorial

RESOURCES
Q & A (531 )
Source Code (3276 )
Articles (365 )
Books (373 )
Components (1647 )
News (898 )
Websites (1208 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Authors
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Feedback
Tell a Friend
Advertise

 

Home > ASP.NET > Member Articles > Visual Studio >
 

Light Intro To Searching LDAP Servers


  Author : lance
  Date Published : 04/29/2002
  Rating No Rating
  Accessed : 5151
   lance

LDAP


 


Lance Robinson

lancer@nsoftware.com


 


 



In this text, I will provide a demonstration for two basic functions of LDAP.

  • Retrieving LDAP DSE Information
  • Performing a basic LDAP entry search to retrieve entry attributes


    Requirements


    To do this, I'll take advantage of the LDAP component included in the IP*Works! toolkit - .Net Edition.
    If you do not have this tool suite, you can download a free fully functional trial at /n software.


    DSE Info


    LDAP DSE Information - or Directory Specific Entry information - is information that all LDAP servers
    will provide so that clients can have access to attributes of the server itself. Some of this information
    can be quite useful. For one example - each LDAP server can actually contain several different directories.
    One of the DSE Attributes is called "namingContexts", and this attribute is a list of base DN's (one for each
    directory) that you can access on this particular server. DSE Information will also tell you which versions of the LDAP
    protocol the server can understand.


    A DSE request is formed by
    a search with the following parameters:

  • Blank DN
  • Search Filter of "objectClass=*"
  • Search Scope of "Base"


    A search performed on the server with the above parameters will result in the server spitting out information about itself.
    In order to form this search with the IP*Works! component, we only need to fill in a few simple properties:



    LDAP1.ServerName = txtServer.Text

    LDAP1.DN = ""

    LDAP1.SearchFilter = "objectClass=*"

    LDAP1.SearchScope = ssBaseObject

    LDAP1.Search




    After this search is complete, a SearchComplete event will fire - at which time we know that we have received
    all of the relevant information from the server and we are free to examine the results. These results are
    provided in the Attr arrays. First, LDAP1.AttrCount provides the number of attributes. LDAP1.AttrType(i) provides
    the type of the ith attribute, and the LDAP1.AttrValue(i) provides the value of the ith attribute.
    One way to extract this data is to add the results to a listbox:



    For i = 0 To LDAP1.AttrCount - 1

          lstResults.AddItem (LDAP1.AttrType(i) & ":" & LDAP1.AttrValue(i))

    Next




    Basic LDAP Entry Query


    LDAP Directories can of course be used to contain any type of information, but most commonly the information you see
    is about people. For example, lets say our server, named NSOFTWARE, contains information about all of the employees
    in the company.


    Lets go ahead and single out one particular employee, Lance Robinson, me. My UID is LRobinson. Our goal is to
    perform a search for all of the attributes of the entry for LRobinson. The first step is to determine the DN
    for that entry.


    Bind and Determine User DN


    When initially connecting to the LDAP server, we can bind anonymously or we can authenticate. For the purposes
    of this document, we'll just bind anonymously. After binding (connecting), we'll issue a search on the base DN
    of my directory for the UID LRobinson. We can determine the base DN's for the servers from the namingContext attributes
    of the DSE search we did above.



    LDAP1.ServerName = txtMyServer.Text

    LDAP1.Bind                                           'anonymously bind to the server

    LDAP1.DN = "NSOFTWARE"                 'The DN to NSOFTWARE, which we obtained from the DSE Search

    LDAP1.SearchFilter = "uid=LRobinson"  'search for this uid

    LDAP1.Search




    For each entry on the server in the directory with DN NSOFTWARE that matches the UID=LRobinson, a SearchResult
    event will fire, reporting the DN of the matching entry. We'll grab this information, since that is what we need
    in order to perform a direct search on this user. In this particular search on my server, the SearchResult event
    fired once, with the following DN: "uid=LRobinson, ou=People, dc=com".


    Query User DN


    From here its easy! Now that we know the DN of the user, simply perform a new search on this DN:



    LDAP1.DN = "uid=LRobinson, ou=People, dc=com"

    LDAP1.SearchFilter = "ObjectClass=*"

    LDAP1.Search




    Now a search will be performed on the LRobinson entry. When the SearchComplete event fires, we know that we
    have all of the information that the server has returned and we can parse through it and do with it what we will.
    Below I am displaying the information as before - to a listbox:



    For i = 0 To LDAP1.AttrCount - 1

         lstResults.AddItem (LDAP1.AttrType(i) & ":" & LDAP1.AttrValue(i))

    Next







    The results will look like the following:




    objectClass: Person

    : organizationalPerson

    : inetorgperson

    : top

    sn: Robinson

    cn: Lance Robinson

    uid: LRobinson

    creatorsName: uid=admin,ou=administrators

    modifiersName: uid=admin,ou=administrators

    createTimestamp: 20010710235642Z

    modifyTimestamp: 20020313152716Z

    mail: lancer@nsoftware.com

    description: Incredibly good-looking

    : Incredibly smart

    roomNumber: 110





    More Information


    For information about the author, please contact
    lancer@nsoftware.com
    .


    For more information about IP*Works! or the LDAP component, please visit /n
    software
    .



    Copyright © 2002, Lance Robinson - All Rights
    Reserved.  For publishing permissions, contact

    lancer@nsoftware.com
    .


     










  •  
       Add Comment  Printer Friendly
       View All Comments  Email to a friend
       Add to my Favourites  Report Bad Submissions  Submit Feedback
       Rating Download PDF version
     
                     Click each image to add
    this page to each site.
     
    Related Articles of ASP.NET
    Random Articles    -     Next Article
     
     
     
    Comments Available
    There are currently...  By : kitkitty18
    6th Jan 2010 06:48 AM

    There are currently few standards that administer the association and presentation of online redhat exam questions, the information that is available to fulfill these objectives can differ widely from cisco certifications resource to microsoft certification resource. In general, references to online works require more information than references to print sources.
     
     
     
     
     
    Welcome Guest Signup
    Member's Panel
    EMAIL
    PASSWORD
    Forgot your password?
    New User? Click Here!
     
    Resend Activation Email!

    Hosting Spotlight


    Product Spotlight


    SEARCH
     



     
     
     
     
     


    Home | Login | About Us | Contact Us | Privacy Policy | Advertising | Feedback Please

    Warning: Unknown(): write failed: Disk quota exceeded (122) in Unknown on line 0

    Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0