Directory Services

Sending LDAP Controls

The following code example retrieves the first 750 objects in the LDAP directory, sorted by the name attribute value of the object.

<!-- SORT by Name  -->
<se:Envelope xmlns:se="">
   <se:Body xmlns="urn:oasis:names:tc:DSML:2:0:core">
	<batchRequest xmlns:xsi="" xmlns:xsd="">
		 <searchRequest dn="dc=fabrikam,dc=com" scope="wholeSubtree" derefAliases="neverDerefAliases" sizeLimit="750">
			<control type="1.2.840.113556.1.4.473" criticality="true">
			 <controlValue xsi:type="xsd:base64Binary">MIQAAAAPMIQAAAAJBARuYW1lAQEA</controlValue>
			 <present name="objectclass"/>
			 <attribute name="name"/>
			 <attribute name="description"/>
			 <attribute name="whenCreated"/>

The <se:Envelope> and <se:Body> SOAP elements wrap the DSML payload. The first element of the DSML payload, <batchRequest>, is the mandatory top-level element for all DSML V2 requests. The <searchRequest> element retrieves the directory objects. The <control> element sends the extended LDAP control to sort the results by object name. The <attribute> elements specify which directory attribute values to return with each associated directory object.

The LDAP control OID ("1.2.840.113556.1.4.473") is the server sort control. For more information about the sort control, go to, and in the left pane, search for the topic LDAP_SERVER_SORT_OID.

The <controlValue> type is encoded by taking the base-64 encoding of the LDAP BER-encoded value of the control.

For more information about how to send and receive SOAP messages, see Transmitting and Receiving SOAP-DSML Messages.