WebLdapBind Function

Action

Exchanges authentication information between the client and the server.

Include file

WebAPI.bdh

Syntax

WebLdapBind( in hLDAP : number,
             in sDN   : string optional,
             in sCred : string optional ): boolean;

Return value

  • true if the bind attempt was completed successfully

  • false otherwise

Parameter Description
hLDAP Handle to a Web connection that was created by WebLdapConnect.
sDN An unambiguous name of the directory object that the client wishes to bind as (optional). This field may take a NULL value for the purposes of anonymous binds.
sCred Authentication information used to authenticate the name, if any, provided in the bind request (optional). This value may be NULL.

Example

const
  LDAP_SIZELIMIT := 100;
  LDAP_TIMELIMIT := 10000;

dclrand
  rsName: RndFile("Gfname.rnd", 20);

dclfunc
  function FWebLdapPrintSearchResults(hLdap: number)
  var
    sName    : string(500);
    nEntries : number;
  begin
    nEntries := 0;

    while WebLdapNextEntry(hLdap, sName, STRING_COMPLETE, false) do
      nEntries := nEntries + 1;
      write("entry: "); write(sName); writeln;

      while WebLdapNextAttribute(hLdap, sName) do
        write(" attrib: "); write(sName); writeln;

        while WebLdapNextValue(hLdap, sName) do
          write(" value: "); write(sName); writeln;
        end;
      end;
    end;

    if (nEntries = 0) then
      write("No entries found");
      writeln;
    end;

    writeln;
  end FWebLdapPrintSearchResults;

dcltrans
  transaction TWebLdap
  var
    sQuery : string(1000);
    hLdap  : number;
    rsName : string;
  begin
    WebLdapConnect(hLdap, "standardhost", WEB_PORT_LDAP);
    WebLdapBind(hLdap, NULL, NULL);

    rsName := "adminname";
    sQuery := "cn=" + rsName;
    if (not WebLdapSearch(hLdap, "", NULL, sQuery, LDAP_SIZELIMIT, LDAP_TIMELIMIT)) then
      write("LDAP Search failed"); writeln;
    else
      FWebLdapPrintSearchResults(hLdap);
    end;

    WebLdapDisconnect(hLdap);
  end TWebLdap;

SilkEssential sample

LDAP.sep