diff --git a/control.go b/control.go index aa68fc83..2c5d6e32 100644 --- a/control.go +++ b/control.go @@ -20,7 +20,7 @@ const ( ControlTypeManageDsaIT = "2.16.840.1.113730.3.4.2" // ControlTypeWhoAmI - https://tools.ietf.org/html/rfc4532 ControlTypeWhoAmI = "1.3.6.1.4.1.4203.1.11.3" - // ControlTypeSubTreeDelete - https://datatracker.ietf.org/doc/html/draft-armijo-ldap-treedelete-02 + // ControlTypeSubtreeDelete - https://datatracker.ietf.org/doc/html/draft-armijo-ldap-treedelete-02 ControlTypeSubtreeDelete = "1.2.840.113556.1.4.805" // ControlTypeMicrosoftNotification - https://msdn.microsoft.com/en-us/library/aa366983(v=vs.85).aspx @@ -232,7 +232,7 @@ func (c *ControlManageDsaIT) GetControlType() string { // Encode returns the ber packet representation func (c *ControlManageDsaIT) Encode() *ber.Packet { - //FIXME + // FIXME packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeManageDsaIT, "Control Type ("+ControlTypeMap[ControlTypeManageDsaIT]+")")) if c.Criticality { @@ -439,18 +439,18 @@ func DecodeControl(packet *ber.Packet) (Control, error) { for _, child := range sequence.Children { if child.Tag == 0 { - //Warning + // Warning warningPacket := child.Children[0] val, err := ber.ParseInt64(warningPacket.Data.Bytes()) if err != nil { return nil, fmt.Errorf("failed to decode data bytes: %s", err) } if warningPacket.Tag == 0 { - //timeBeforeExpiration + // timeBeforeExpiration c.Expire = val warningPacket.Value = c.Expire } else if warningPacket.Tag == 1 { - //graceAuthNsRemaining + // graceAuthNsRemaining c.Grace = val warningPacket.Value = c.Grace } @@ -524,16 +524,21 @@ func NewControlBeheraPasswordPolicy() *ControlBeheraPasswordPolicy { } } +// ControlSubtreeDelete implements the subtree delete control described in +// https://datatracker.ietf.org/doc/html/draft-armijo-ldap-treedelete-02 type ControlSubtreeDelete struct{} +// GetControlType returns the OID func (c *ControlSubtreeDelete) GetControlType() string { return ControlTypeSubtreeDelete } +// NewControlSubtreeDelete returns a ControlSubtreeDelete control. func NewControlSubtreeDelete() *ControlSubtreeDelete { return &ControlSubtreeDelete{} } +// Encode returns the ber packet representation func (c *ControlSubtreeDelete) Encode() *ber.Packet { packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeSubtreeDelete, "Control Type ("+ControlTypeMap[ControlTypeSubtreeDelete]+")")) diff --git a/debug.go b/debug.go index 74cc65a4..6f89b4a0 100644 --- a/debug.go +++ b/debug.go @@ -5,7 +5,7 @@ import ( ) // debugging type -// - has a Printf method to write the debug output +// - has a Printf method to write the debug output type debugging bool // Enable controls debugging mode. diff --git a/dn.go b/dn.go index adbdb786..9ff08db7 100644 --- a/dn.go +++ b/dn.go @@ -286,7 +286,7 @@ func (a *AttributeTypeAndValue) Equal(other *AttributeTypeAndValue) bool { return strings.EqualFold(a.Type, other.Type) && a.Value == other.Value } -// Equal returns true if the DNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). +// EqualFold returns true if the DNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). // Returns true if they have the same number of relative distinguished names // and corresponding relative distinguished names (by position) are the same. // Case of the attribute type and value is not significant @@ -318,7 +318,7 @@ func (d *DN) AncestorOfFold(other *DN) bool { return true } -// Equal returns true if the RelativeDNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). +// EqualFold returns true if the RelativeDNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). // Case of the attribute type is not significant func (r *RelativeDN) EqualFold(other *RelativeDN) bool { if len(r.Attributes) != len(other.Attributes) { diff --git a/moddn.go b/moddn.go index ec246d1f..14a2ff76 100644 --- a/moddn.go +++ b/moddn.go @@ -23,7 +23,9 @@ type ModifyDNRequest struct { // RDN of the given DN. // // A call like -// mdnReq := NewModifyDNRequest("uid=someone,dc=example,dc=org", "uid=newname", true, "") +// +// mdnReq := NewModifyDNRequest("uid=someone,dc=example,dc=org", "uid=newname", true, "") +// // will setup the request to just rename uid=someone,dc=example,dc=org to // uid=newname,dc=example,dc=org. func NewModifyDNRequest(dn string, rdn string, delOld bool, newSup string) *ModifyDNRequest { @@ -40,7 +42,7 @@ func NewModifyDNRequest(dn string, rdn string, delOld bool, newSup string) *Modi // // Refer NewModifyDNRequest for other parameters func NewModifyDNWithControlsRequest(dn string, rdn string, delOld bool, - newSup string, controls []Control) *ModifyDNRequest { + newSup string, controls []Control) *ModifyDNRequest { return &ModifyDNRequest{ DN: dn, NewRDN: rdn, diff --git a/request.go b/request.go index 7eef1ce6..b64f232d 100644 --- a/request.go +++ b/request.go @@ -9,7 +9,8 @@ import ( var ( errRespChanClosed = errors.New("ldap: response channel closed") errCouldNotRetMsg = errors.New("ldap: could not retrieve message") - ErrNilConnection = errors.New("ldap: conn is nil, expected net.Conn") + // ErrNilConnection is returned if doRequest is called with a nil connection. + ErrNilConnection = errors.New("ldap: conn is nil, expected net.Conn") ) type request interface { diff --git a/unbind.go b/unbind.go index 6c411cd1..10cf75c6 100644 --- a/unbind.go +++ b/unbind.go @@ -6,6 +6,7 @@ import ( ber "github.com/go-asn1-ber/asn1-ber" ) +// ErrConnUnbound is returned when Unbind is called on an already closing connection. var ErrConnUnbound = NewError(ErrorNetwork, errors.New("ldap: connection is closed")) type unbindRequest struct{} diff --git a/v3/control.go b/v3/control.go index aa68fc83..2c5d6e32 100644 --- a/v3/control.go +++ b/v3/control.go @@ -20,7 +20,7 @@ const ( ControlTypeManageDsaIT = "2.16.840.1.113730.3.4.2" // ControlTypeWhoAmI - https://tools.ietf.org/html/rfc4532 ControlTypeWhoAmI = "1.3.6.1.4.1.4203.1.11.3" - // ControlTypeSubTreeDelete - https://datatracker.ietf.org/doc/html/draft-armijo-ldap-treedelete-02 + // ControlTypeSubtreeDelete - https://datatracker.ietf.org/doc/html/draft-armijo-ldap-treedelete-02 ControlTypeSubtreeDelete = "1.2.840.113556.1.4.805" // ControlTypeMicrosoftNotification - https://msdn.microsoft.com/en-us/library/aa366983(v=vs.85).aspx @@ -232,7 +232,7 @@ func (c *ControlManageDsaIT) GetControlType() string { // Encode returns the ber packet representation func (c *ControlManageDsaIT) Encode() *ber.Packet { - //FIXME + // FIXME packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeManageDsaIT, "Control Type ("+ControlTypeMap[ControlTypeManageDsaIT]+")")) if c.Criticality { @@ -439,18 +439,18 @@ func DecodeControl(packet *ber.Packet) (Control, error) { for _, child := range sequence.Children { if child.Tag == 0 { - //Warning + // Warning warningPacket := child.Children[0] val, err := ber.ParseInt64(warningPacket.Data.Bytes()) if err != nil { return nil, fmt.Errorf("failed to decode data bytes: %s", err) } if warningPacket.Tag == 0 { - //timeBeforeExpiration + // timeBeforeExpiration c.Expire = val warningPacket.Value = c.Expire } else if warningPacket.Tag == 1 { - //graceAuthNsRemaining + // graceAuthNsRemaining c.Grace = val warningPacket.Value = c.Grace } @@ -524,16 +524,21 @@ func NewControlBeheraPasswordPolicy() *ControlBeheraPasswordPolicy { } } +// ControlSubtreeDelete implements the subtree delete control described in +// https://datatracker.ietf.org/doc/html/draft-armijo-ldap-treedelete-02 type ControlSubtreeDelete struct{} +// GetControlType returns the OID func (c *ControlSubtreeDelete) GetControlType() string { return ControlTypeSubtreeDelete } +// NewControlSubtreeDelete returns a ControlSubtreeDelete control. func NewControlSubtreeDelete() *ControlSubtreeDelete { return &ControlSubtreeDelete{} } +// Encode returns the ber packet representation func (c *ControlSubtreeDelete) Encode() *ber.Packet { packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeSubtreeDelete, "Control Type ("+ControlTypeMap[ControlTypeSubtreeDelete]+")")) diff --git a/v3/debug.go b/v3/debug.go index 74cc65a4..6f89b4a0 100644 --- a/v3/debug.go +++ b/v3/debug.go @@ -5,7 +5,7 @@ import ( ) // debugging type -// - has a Printf method to write the debug output +// - has a Printf method to write the debug output type debugging bool // Enable controls debugging mode. diff --git a/v3/dn.go b/v3/dn.go index adbdb786..9ff08db7 100644 --- a/v3/dn.go +++ b/v3/dn.go @@ -286,7 +286,7 @@ func (a *AttributeTypeAndValue) Equal(other *AttributeTypeAndValue) bool { return strings.EqualFold(a.Type, other.Type) && a.Value == other.Value } -// Equal returns true if the DNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). +// EqualFold returns true if the DNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). // Returns true if they have the same number of relative distinguished names // and corresponding relative distinguished names (by position) are the same. // Case of the attribute type and value is not significant @@ -318,7 +318,7 @@ func (d *DN) AncestorOfFold(other *DN) bool { return true } -// Equal returns true if the RelativeDNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). +// EqualFold returns true if the RelativeDNs are equal as defined by rfc4517 4.2.15 (distinguishedNameMatch). // Case of the attribute type is not significant func (r *RelativeDN) EqualFold(other *RelativeDN) bool { if len(r.Attributes) != len(other.Attributes) { diff --git a/v3/moddn.go b/v3/moddn.go index ec246d1f..14a2ff76 100644 --- a/v3/moddn.go +++ b/v3/moddn.go @@ -23,7 +23,9 @@ type ModifyDNRequest struct { // RDN of the given DN. // // A call like -// mdnReq := NewModifyDNRequest("uid=someone,dc=example,dc=org", "uid=newname", true, "") +// +// mdnReq := NewModifyDNRequest("uid=someone,dc=example,dc=org", "uid=newname", true, "") +// // will setup the request to just rename uid=someone,dc=example,dc=org to // uid=newname,dc=example,dc=org. func NewModifyDNRequest(dn string, rdn string, delOld bool, newSup string) *ModifyDNRequest { @@ -40,7 +42,7 @@ func NewModifyDNRequest(dn string, rdn string, delOld bool, newSup string) *Modi // // Refer NewModifyDNRequest for other parameters func NewModifyDNWithControlsRequest(dn string, rdn string, delOld bool, - newSup string, controls []Control) *ModifyDNRequest { + newSup string, controls []Control) *ModifyDNRequest { return &ModifyDNRequest{ DN: dn, NewRDN: rdn, diff --git a/v3/request.go b/v3/request.go index 7eef1ce6..b64f232d 100644 --- a/v3/request.go +++ b/v3/request.go @@ -9,7 +9,8 @@ import ( var ( errRespChanClosed = errors.New("ldap: response channel closed") errCouldNotRetMsg = errors.New("ldap: could not retrieve message") - ErrNilConnection = errors.New("ldap: conn is nil, expected net.Conn") + // ErrNilConnection is returned if doRequest is called with a nil connection. + ErrNilConnection = errors.New("ldap: conn is nil, expected net.Conn") ) type request interface { diff --git a/v3/unbind.go b/v3/unbind.go index 6c411cd1..10cf75c6 100644 --- a/v3/unbind.go +++ b/v3/unbind.go @@ -6,6 +6,7 @@ import ( ber "github.com/go-asn1-ber/asn1-ber" ) +// ErrConnUnbound is returned when Unbind is called on an already closing connection. var ErrConnUnbound = NewError(ErrorNetwork, errors.New("ldap: connection is closed")) type unbindRequest struct{}