Skip to content
go-directoryPublic

About

RFC4511 / ITU-T rec. X.511 wire protocol components and encoding

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

protocol

Package protocol implements ASN.1 wire protocol definitions and codecs for directory services, as defined in RFC 4511, ITU-T rec. X.511, et al. In particular, "request", "response" and "control" components represent the bulk of this package.

This package was designed specifically for use by the Go Directory Project.

License

This package is released under the terms of the MIT license. See the LICENSE file in the repository root for details.

Status

This package is undergoing heavy development and is prone to breaking changes at any time. It is not yet suitable for use in any production environment.

Rank

The protocol package and its included package subdirectories ("request", etc) are regarded as "mid rank" packages, in that they "sit" between "high rank" packages such as "dsa" and "low rank" packages such as "common" and "encoding".

About

The protocol package defines types based upon the various "request" and "response" ASN.1 constructs observed throughout the aforementioned documents. These constructs are used by an entity -- often a DSA or a DUA -- for communicating via the relevant directory protocol(s).

For example, a client -- via a DUA -- wishes to perform a search of their local directory service. This would require the following of the requesting party:

  • Connect to the DSA, likely involving TLS
  • Construct a BindRequest RFC4511 type (bearing the [APPLICATION 0] ASN.1 tag)
  • Add the BindRequest as the "ProtocolOp" component of an LDAPMessage, possibly including LDAP Control instructions
  • Encode the LDAPMessage as ASN.1 BER according to RFC4511
  • Write the encoding to the DSA connection for transmittal
  • Await DSA response

The DSA, upon receipt of the above payload, is expected to take the following actions:

  • Decode LDAPMessage payload, determine kind of "ProtocolOp"
  • De-envelope the BindRequest and process it (for the purposes of this example, it is assumed the request is legitimate)
  • Prepare an LDAPMessage, except the "ProtocolOp" is a BindResponse which circumscribes an LDAP Result Code of zero (0) for success
  • Encode the LDAPMessage envelope payload
  • Write the encoding to the connection established by the DUA
  • Await further instructions

Only once a successful BindResponse is received can the requesting party submit the desired SearchRequest.

The purpose of this package is wire protocol exchanges not unlike the above, whether these exchanges occur between a DUA and DSA, or between multiple DSAs.

For example:

	var bind BindRequest
	// add credentials, SASL mechanisms, etc., if needed

	var req LDAPMessage
	req.ProtocolOp = bind
	// Optionally add controls

	encoding, err := req.Encode()
	// check error

	// Write to encoding connection, e.g.:
        _, err := r.conn.Write(encoding)

	//////////////////////////////////
	// Wait for encoded reply from DSA
	//////////////////////////////////

	var resp LDAPMessage
	err = resp.Decode(replyBytes)
	// check error

	bresp, ok := resp.ProtocolOp.(BindResponse)
	// check bind response
	// if OK, continue with other request/response exchanges
	// as needed...

About

RFC4511 / ITU-T rec. X.511 wire protocol components and encoding

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages