ExamplesExamples
Home > Books > NetKernel Technologies > LDAP > Examples

Rate this page:
Really useful
Satisfactory
Not helpful
Confusing
Incorrect
Unsure
Extra comments:


Examples

Add Example

This DSML request adds a new entry with the Distinguished Name cn=Test,ou=1060Research,dc=1060,dc=org.

<ds:batchRequest xmlns:ds="urn:oasis:names:tc:DSML:2:0:core" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" processing="parallel">
  <ds:addRequest dn="cn=Test,ou=1060Research,dc=1060,dc=org">
    <ds:attr name="objectclass">
      <ds:value>top</ds:value>
    </ds:attr>
    <ds:attr name="objectclass">
      <ds:value>person</ds:value>
    </ds:attr>
    <ds:attr name="objectclass">
      <ds:value>organizationalPerson</ds:value>
    </ds:attr>
    <ds:attr name="objectclass">
      <ds:value>inetOrgPerson</ds:value>
    </ds:attr>
    <ds:attr name="cn">
      <ds:value>Test</ds:value>
    </ds:attr>
    <ds:attr name="sn">
      <ds:value>Test</ds:value>
    </ds:attr>
    <ds:attr name="givenName">
      <ds:value>Test</ds:value>
    </ds:attr>
    <ds:attr name="title">
      <ds:value>A Test Addition</ds:value>
    </ds:attr>
  </ds:addRequest>
</ds:batchRequest>

When this request is made with the ldapBatch service it returns a DSML response document.

Search Example

This DSML performs two search. The first searches for all entries with a surname (sn) matching either 'rod' or 'but'. The second search looks for sn fields with 'Tes'.

<ds:batchRequest xmlns:ds="urn:oasis:names:tc:DSML:2:0:core" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" processing="parallel">
  <ds:searchRequest derefAliases="neverDerefAliases" dn="dc=1060,dc=org" scope="wholeSubtree" sizeLimit="1000">
    <ds:filter>
      <ds:or>
        <ds:substrings name="sn">
          <ds:any>rod</ds:any>
        </ds:substrings>
        <ds:substrings name="sn">
          <ds:any>but</ds:any>
        </ds:substrings>
      </ds:or>
    </ds:filter>
  </ds:searchRequest>
  <ds:searchRequest derefAliases="neverDerefAliases" dn="dc=1060,dc=org" scope="wholeSubtree" sizeLimit="1000">
    <ds:filter>
      <ds:substrings name="sn">
        <ds:any>Tes</ds:any>
      </ds:substrings>
    </ds:filter>
  </ds:searchRequest>
</ds:batchRequest>

The DSML response contains the matching entries for each of the searches.

Multi-step Example

Here is complex example - the operations performed sequentially are as follows...

  1. Add a new entry under the 1060Research organization unit
  2. Search for sn matching 'Test'
  3. Modify the entry Test - change mail, sn, etc
  4. Change the distinguished name for Test to cn=John Smith,ou=1060Research,dc=1060,dc=org
  5. Assert that the sn is Smith for cn=John Smith,ou=1060Research,dc=1060,dc=org
  6. Delete the John Smith entry

<ds:batchRequest xmlns:ds="urn:oasis:names:tc:DSML:2:0:core" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" processing="sequential">
  <!-- *************** Add a new entry under the 1060Research organization unit *************** -->
  <ds:addRequest dn="cn=Test,ou=1060Research,dc=1060,dc=org">
    <ds:attr name="objectclass">
      <ds:value>top</ds:value>
    </ds:attr>
    <ds:attr name="objectclass">
      <ds:value>person</ds:value>
    </ds:attr>
    <ds:attr name="objectclass">
      <ds:value>organizationalPerson</ds:value>
    </ds:attr>
    <ds:attr name="objectclass">
      <ds:value>inetOrgPerson</ds:value>
    </ds:attr>
    <ds:attr name="cn">
      <ds:value>Test</ds:value>
    </ds:attr>
    <ds:attr name="sn">
      <ds:value>Test</ds:value>
    </ds:attr>
    <ds:attr name="givenName">
      <ds:value>Test</ds:value>
    </ds:attr>
    <ds:attr name="title">
      <ds:value>A Test Addition</ds:value>
    </ds:attr>
  </ds:addRequest>
  <!-- *************** Search for sn matching 'Test' *************** -->
  <ds:searchRequest derefAliases="neverDerefAliases" dn="dc=1060,dc=org" scope="wholeSubtree" sizeLimit="1000">
    <ds:filter>
      <ds:substrings name="sn">
        <ds:any>Test</ds:any>
      </ds:substrings>
    </ds:filter>
  </ds:searchRequest>
  <!-- *************** Modify Test - change mail, sn, etc *************** -->
  <ds:modifyRequest dn="cn=Test,ou=1060Research,dc=1060,dc=org">
    <ds:modification name="mail" operation="add">
      <value>[email protected]</value>
    </ds:modification>
    <ds:modification name="sn" operation="replace">
      <value>Smith</value>
    </ds:modification>
    <ds:modification name="mail" operation="replace">
      <value>[email protected]</value>
    </ds:modification>
    <ds:modification name="givenName" operation="replace">
      <value>smithy</value>
    </ds:modification>
  </ds:modifyRequest>
  <!-- *************** Change the distinguished name to cn=John Smith,ou=1060Research,dc=1060,dc=org *************** -->
  <modDNRequest deleteoldrdn="true" dn="cn=Test,ou=1060Research,dc=1060,dc=org" newSuperior="ou=1060research,dc=1060,dc=org" newrdn="cn=John Smith" />
  <ds:searchRequest derefAliases="neverDerefAliases" dn="dc=1060,dc=org" scope="wholeSubtree" sizeLimit="1000">
    <ds:filter>
      <ds:substrings name="sn">
        <ds:any>Smith</ds:any>
      </ds:substrings>
    </ds:filter>
  </ds:searchRequest>
  <!-- *************** Assert that sn is Smith for this dn *************** -->
  <ds:compareRequest dn="cn=John Smith,ou=1060Research,dc=1060,dc=org">
    <ds:assertion name="sn">
      <ds:value>Smith</ds:value>
    </ds:assertion>
  </ds:compareRequest>
  <!-- *************** Delete the John Smith entry *************** -->
  <ds:delRequest dn="cn=John Smith,ou=1060Research,dc=1060,dc=org" />
</ds:batchRequest>
© 2003-2007, 1060 Research Limited. 1060 registered trademark, NetKernel trademark of 1060 Research Limited.