Figure 5: A sample ASP page that uses the LDAP COM API

<%@ Language=JScript%>
   <html>
   <body>
   <%
      //create LDAP COM object instance
      LDAPObj = Server.CreateObject("ISSNKB.LdapConnection")
        
      //connect anonymously        
      LDAPObj.connectAnonymously("goldfish.eng.iss.net", 389)
      Response.write("Connect to the data source using LDAP<BR>")
        
      //Search company organization units
      LDAPObj.search("ou=Company,o=eng.iss.net",1,
         "objectClass=*","",false)
      var numberOfSearchEntries = LDAPObj.SearchResultCount();
      Response.write("<BR>One level search under the company 
         organization unit returned the following entries:
         "+"<BR>")
    
      //loop through the entries
      for (var i=0; i <= numberOfSearchEntries; i++){
         var SearchResults = LDAPObj.nextSearchResultEntry(false)
         Response.write(SearchResults+"<BR>")
      }
    
      //Add an entry 
      var dn = 
         "uid=MRichards,cn=Application Developers,
         description=Mountain View,description=California,
         description=United States,ou=Engineering,ou=Company,
         o=eng.iss.net"
      var oval = 
         "objectclass=top,person,organizationalPerson,
         inetOrgPerson;"
      oval = 
         oval+"cn=Monica Richards;sn=Richards;
         givenname=Monica, Richards;
         telephonenumber=+1 678 123 4567"

      Response.write("Create entry for application developer 
         Mrs. Monica Richards with the following dn:<BR>"+dn)
      LDAPObj.createEntry(dn,oval)
        
      //modify the entry by adding e-mail address, deleting given 
      //name and changing the telephone number
      var mod = 
         "a:mail=brichards@company.com;
          d:givenname=Monica, Richards;
          r:telephonenumber=+1 770 123 4567" 
      Response.write("<BR><BR>Modify attribute values:<BR>"+mod)
      LDAPObj.modifyEntry(dn,mod);
        
      //delete the entry
      LDAPObj.deleteEntry(dn)
      Response.write("<BR><BR> Delete the just added entry<BR>")
        
      //disconnect from LDAP
      disconnected = LDAPObj.disconnect()    
      Response.write(
         "<BR>Disconnect client from the data source<BR>")
   %>
   </body>
   </html>