Table of Contents
LDAP4D Directory at A Dog And His Boy

LDAP4D Directory - Protocol Handling

   

About this section...

This section describes the methods used to perform selected protocol operations specified in RFC 2251.
These methods generate or parse BER encoded content that can be used with LDAP_Message_Send to request an action from an LDAP server.

To simplify usage and development of this component many aspects of LDAP v3 are not implemented. Primarily, LDAP4D Directory is designed to return search results for email clients.



LDAPD_BindResponse

Syntax:

blob := LDAPD_BindResponse ( iResultCode:LI ; tMatchedDN:T  tErrorMessage:T )

Description:

Create a BER encoded bind response.

Warning:

none

Note:

SASL Authentication option is NOT supported. See See RFC 2251 4.1.10.

Params:

In/Out

Parameter



Example or note

->

resultcode

Longint
The result of the bind attempt.

success = 0

->

matchedDN

Text

The matched distinguished name. Generally there is not a reason to send anything.

optional

->

errorMessage

Text

Any text you want to send along

optional

<-

result

Blob

BER encoded content of Bind message

 

Example:

$oBlob := LDAPD_BindResponse(0;$tPassword;"Woohoo! Success")

LDAPD_GetMessageID

Syntax:

messageID := LDAPD_GetMessageID (->blob)

Description:

Get the message ID from an input stream.

Warning:

This will consume the message ID (or as much as it gets through) from the blob.
Check LDAPD_iError to see if the function executed successfully.

Note:

The message ID pulled from a SearchRequest should be used when sending results (SearchResultEntry and SearchResDone) back to the client.

Params:

In/Out

Parameter

Type

Description

Example or note

->

inputStream

Pointer

Pointer to blob input buffer.

 

<-

result

Longint

The message ID

 

Example:

$iMessageID := LDAPD_GetMessageID(->oBlob)


LDAPD_ParseBindRequest

Syntax:

result := LDAP_ParseBindRequest (->oBlob)

Description:

Given a presumed BER encoded blob, pull out an expected BindRequest

Warning:

This will consume the bind request (or as much as it gets through) from the blob.

Note:

Generally called from one of the request handlers.
Check LDAPD_tResultErrorMessage on failure.

Params:

In/Out

Parameter

Type

 

Example or note

  ->
inputStream
Pointer
Pointer to blob received via LDAPD_TCP_Receive

<-

result

Boolean

Success or failure (0 or 1)

 

Example:

$flag := LDAPD_ParseBindRequest (->oBlob)


LDAPD_ParseSearchRequest

Syntax:

$flag := LDAPD_ParseSearchRequest ( pBlob:P; pAttributeNames:P; pAttributeFieldPointers:P; pSearchAttributes:P;  pSearchValues:P; pSearchOperators:P; pAttributeModifiers:P; pRequestedAttributes:P  )

Description:

Given a presumed BER encoded blob, parse an expected SearchRequest and put acquired values into arrays so that a search can be built.

Warning:

This will consume the search request (or as much as it gets through) from the blob.

Note:

Generally called from one of the request handlers.

If successful, LDAP_SearchFilter will be populated.
On failure check LDAPD_tResultErrorMessage .

SearchValues will be paired with SearchAttributes. SearchOperators will correspond with values in the LDAP_SearchFilter and will have the following values "and", "or", "not".
AttributeFieldPointers will be set to those that match fields set in LDAPDu_MapFields.
Attribute Modifiers will have the following values "initial", "any", "final", ">=", "<=", "present", "approxMatch". They are used to create the appropriate SQL search statement.
Requested Attributes will be checked against AttributeNames set in LDAPDu_MapFields.

Also, LDAPD_NumOperators will be set. This will give LDAPDu_FilterOps2Query enough information to build a query.


Params:

In/Out

Parameter

Type

   

Example or note

->

pBlob

Pointer

Pointer to blob of presumed BER

 

->

pAttributeNames

Longint

pointer to ta_LDAPD_AttributeNames

 

->
pAttributeFieldPointers

Longint

pointer to pa_LDAPD_AttributeFieldPointers

 

->
pSearchAttributes

Longint

pointer to taLDAPD_SearchAttributes

 

->

pSearchValues

Longint

pointer to taLDAPD_SearchValues

 

->
pSearchOperators

Longint

pointer to taLDAPD_SearchOperators

 

->

pAttributeModifiers

Longint

pointer to  ta_LDAPD_AttributeModifiers

 

->
pRequestedAttributes

Longint

pointer to ta_LDAPD_RequestedAttributes

 

<-

result

Boolean

Success or failure (0 or 1)

 

Example:

$flag :=LDAPD_ParseSearchRequest(->oBlob)


LDAPD_SearchResultEntry

Syntax:

result := LDAPD_SearchResultEntry ( distinguishedName;T ; pAttributeTypes:P ; pAttributeValues:P )

Description:

Create a BER encoded LDAP SearchResultEntry that can then be bundled into an LDAP message and sent back to requesting client.

Warning:

Only single attribute values are supported.

Note:

  `$1 = text = distinguished name
  `$2 = pointer = pointer to text array of attribute names
  `$3 = pointer = pointer to text array of attribute values

The arrays of attribute names and attribute values must be of the same length.
The Distinguished name's fomat is probably not going to be validated anywhere, so you can use what you like. FWIW, there exists RFC 4514:  String Representation of Distinguished Names .
When returning multiple results finish them off with an LDAPD_SearchResultDone.

Params:

In/Out

Parameter

Type

   

Example or note

->

distinguishedName

Text

distinguished name of the entry. No particular standard need be followed.

 

->

pAttributeNames

Pointer

pointer to a text array of attribute names

 

->

pAttributeValues

Pointer

pointer to a text array of attribute values

 

<-

result

Blob

BER encoded content of SearchResultEntry message

 

Example:

$tText :=LDAPD_SearchResultEntry("uid=tswenson, o=dogboy";->at_attributeArray;->at_attributeValues)

LDAPD_SearchResultDone

Syntax:

blob := LDAPD_SearchResultDone ( distinguishedName;T )

Description:

Create a BER encoded SearchResDone message content.

Warning:

 

Note:

 Send this with LDAPD_MessageSend

Params:

In/Out

Parameter

Type

   

Example or note

  ->
resultCode
Boolean
success or failure

  ->
matchedDN
Text
matched DN - no particular form need be followed.

  ->
errorMessage
Text
anything you wish

<-

result

Blob

BER encoded Search Result Done message.

 

Example:

$blob := LDAP_SearchResultDone($tDN;"some made up DN";"")

Back to top