ldif

package module
v0.0.0-...-9d41482 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 12 Imported by: 0

README

ldif

Utilities for working with ldif data. This implements most of RFC 2849.

Change Entries

Support for moddn / modrdn changes is missing (in Unmarshal and Marshal) - github.com/go-ldap/ldap/v3 does not support it currently

Controls

Only simple controls without control value are supported, currently just Manage DSA IT - oid: 2.16.840.1.113730.3.4.2

URLs

URL schemes in an LDIF like jpegPhoto;binary:< file:///usr/share/photos/someone.jpg are only supported for the "file" scheme like in the example above

Documentation

Overview

Package ldif contains utilities for working with ldif data

Package ldif contains an LDIF parser and marshaller (RFC 2849).

Index

Constants

This section is empty.

Variables

View Source
var ErrMixed = errors.New("cannot mix change records and content records")

ErrMixed is the error, that we cannot mix change records and content records in one LDIF

Functions

func Dump

func Dump(fh io.Writer, fw int, entries ...interface{}) error

Dump writes the given entries to the io.Writer.

The entries argument can be *ldap.Entry or a mix of *ldap.AddRequest, *ldap.DelRequest, *ldap.ModifyRequest and *ldap.ModifyDNRequest or slices of any of those.

See Marshal() for the fw argument.

func Marshal

func Marshal(l *LDIF) (data string, err error)

Marshal returns an LDIF string from the given LDIF.

The default line lenght is 76 characters. This can be changed by setting the fw parameter to something else than 0. For a fold width < 0, no folding will be done, with 0, the default is used.

func Unmarshal

func Unmarshal(r io.Reader, l *LDIF) (err error)

Unmarshal parses the LDIF from the given io.Reader into the LDIF struct. The caller is responsible for closing the io.Reader if that is needed.

Types

type Entry

type Entry struct {
	Entry  *ldap.Entry
	Add    *ldap.AddRequest
	Del    *ldap.DelRequest
	Modify *ldap.ModifyRequest
}

Entry is one entry in the LDIF

type LDIF

type LDIF struct {
	Entries []*Entry
	Version int

	FoldWidth int
	Controls  bool
	// contains filtered or unexported fields
}

The LDIF struct is used for parsing an LDIF. The Controls is used to tell the parser to ignore any controls found when parsing (default: false to ignore the controls). FoldWidth is used for the line lenght when marshalling.

func Parse

func Parse(str string) (l *LDIF, err error)

Parse wraps Unmarshal to parse an LDIF from a string

func ParseWithControls

func ParseWithControls(str string) (l *LDIF, err error)

ParseWithControls wraps Unmarshal to parse an LDIF from a string, controls are added to change records

func ToLDIF

func ToLDIF(entries ...interface{}) (*LDIF, error)

ToLDIF puts the given arguments in an LDIF struct and returns it.

The entries argument can be *ldap.Entry or a mix of *ldap.AddRequest, *ldap.DelRequest, *ldap.ModifyRequest and *ldap.ModifyDNRequest or slices of any of those.

func (*LDIF) AllEntries

func (l *LDIF) AllEntries() (entries []*ldap.Entry)

AllEntries returns all *ldap.Entries in the LDIF

func (*LDIF) Apply

func (l *LDIF) Apply(conn ldap.Client, continueOnErr bool) error

Apply sends the LDIF entries to the server and does the changes as given by the entries.

All *ldap.Entry are converted to an *ldap.AddRequest.

By default, it returns on the first error. To continue with applying the LDIF, set the continueOnErr argument to true - in this case the errors are logged with log.Printf()

type ParseError

type ParseError struct {
	Line    int
	Message string
}

The ParseError holds the error message and the line in the ldif where the error occurred.

func (*ParseError) Error

func (e *ParseError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL