WebLdapControlAdd Function

Action

Adds a control to the next WebLdapAdd, WebLdapCompare, WebLdapDelete, WebLdapModify, WebLdapRename, WebLdapSearch or WebLdapExtendedOperation function call. To assign multiple controls, this function must be called repeatedly.

Include file

WebAPI.bdh

Syntax

WebLdapControlAdd( in hLdap       : number, 
                   in sOid        : string, 
                   in sData       : string allownull, 
                   in nLength     : number, 
                   in bIsCritical : boolean, 
                   in nFlag       : number ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hLdap Handle to a Web connection that was created with WebLdapConnect.
sOid The object identifier of the control.
sData

The data associated with the control

  • If you want to specify a zero-length value, set nLength to 0 and sData to a zero-length string.

  • To indicate that no data is associated with the control, set sData to NULL.

nLength The length of sData.
bIsCritical Specifies whether the control is critical to the operation.
nFlag

Specifies the kind of control. This parameter is one of the following:

  • WEB_LDAP_SERVER_CONTROL

  • WEB_LDAP_CLIENT_CONTROL

Example

const
  LDAP_SIZELIMIT := 100;
  LDAP_TIMELIMIT := 10000;
transaction TWebLdap 
  var
  hLdap, nDataLen, nLenOid : number;
  sOid, sData              : string;
  bIsCritic                : boolean;
 const 
    // this is a representation of a server-side sorting control 
    // which specifies that results shall be sorted by cn in 
    // ascending order
    cControlData:="\h300630040402636E"; 
  begin
    WebLdapConnect(hLdap, "standardhost", WEB_PORT_LDAP,
                 WEB_LDAP_FLAG_VERSION3);
    WebLdapBind(hLdap, "cn=adminname", "password"); 
    WebLdapControlAdd(hLdap,"1.2.840.113556.1.4.473", cControlData, 
                      sizeof(cControlData), true, WEB_LDAP_SERVER_CONTROL);  
    if (not WebLdapSearch(hLdap, "o=MyCompany", NULL, "cn=*",
      LDAP_SIZELIMIT, LDAP_TIMELIMIT, 0)) then 
      write("LDAP Search failed"); writeln; 
    else
      TWebLdapPrintSearchResults(hLdap); 
      write("Search ok"); writeln; 
    end;

    nDataLen := 100; //returned sData size is max 100
    nLenOid := sizeof(sOid);

    WebLdapControlGet(hLdap, sOid, nLenOid, sData, nDataLen, bIsCritic); 

    write("result control - "); 
    write("oid:"); write(sOid); 
    write(", data:"); write(sData); 
    writeln;   WebLdapDisconnect(hLdap); 
  end TWebLdap;