diff options
author | Samuel Stauffer <samuel@descolada.com> | 2014-03-19 22:05:10 +0100 |
---|---|---|
committer | Samuel Stauffer <samuel@descolada.com> | 2014-03-19 22:05:10 +0100 |
commit | 4e3f3713c8f6debc9a2844af538094968142a714 (patch) | |
tree | 0c479514925aabf0bf8776b7756d8a7204820aec /ldap.go | |
parent | Stylistic fixes, update imports, and some format string fixes (diff) | |
download | ldap-4e3f3713c8f6debc9a2844af538094968142a714.tar ldap-4e3f3713c8f6debc9a2844af538094968142a714.tar.gz ldap-4e3f3713c8f6debc9a2844af538094968142a714.tar.bz2 ldap-4e3f3713c8f6debc9a2844af538094968142a714.tar.lz ldap-4e3f3713c8f6debc9a2844af538094968142a714.tar.xz ldap-4e3f3713c8f6debc9a2844af538094968142a714.tar.zst ldap-4e3f3713c8f6debc9a2844af538094968142a714.zip |
Diffstat (limited to 'ldap.go')
-rw-r--r-- | ldap.go | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -153,7 +153,7 @@ var LDAPResultCodeMap = map[uint8]string{ func addLDAPDescriptions(packet *ber.Packet) (err *Error) { defer func() { if r := recover(); r != nil { - err = NewError(ErrorDebugging, errors.New("Cannot process packet to add descriptions")) + err = NewError(ErrorDebugging, errors.New("ldap: cannot process packet to add descriptions")) } }() packet.Description = "LDAP Response" @@ -229,11 +229,11 @@ func addControlDescriptions(packet *ber.Packet) { case ControlTypePaging: value.Description += " (Paging)" if value.Value != nil { - value_children := ber.DecodePacket(value.Data.Bytes()) + valueChildren := ber.DecodePacket(value.Data.Bytes()) value.Data.Truncate(0) value.Value = nil - value_children.Children[1].Value = value_children.Children[1].Data.Bytes() - value.AppendChild(value_children) + valueChildren.Children[1].Value = valueChildren.Children[1].Data.Bytes() + value.AppendChild(valueChildren) } value.Children[0].Description = "Real Search Control Value" value.Children[0].Children[0].Description = "Paging Size" @@ -286,21 +286,17 @@ func (e *Error) String() string { return fmt.Sprintf("LDAP Result Code %d %q: %s", e.ResultCode, LDAPResultCodeMap[e.ResultCode], e.Err.Error()) } -func NewError(ResultCode uint8, Err error) *Error { - return &Error{ResultCode: ResultCode, Err: Err} +func NewError(resultCode uint8, err error) *Error { + return &Error{ResultCode: resultCode, Err: err} } func getLDAPResultCode(packet *ber.Packet) (code uint8, description string) { if len(packet.Children) >= 2 { response := packet.Children[1] if response.ClassType == ber.ClassApplication && response.TagType == ber.TypeConstructed && len(response.Children) == 3 { - code = uint8(response.Children[0].Value.(uint64)) - description = response.Children[2].Value.(string) - return + return uint8(response.Children[0].Value.(uint64)), response.Children[2].Value.(string) } } - code = ErrorNetwork - description = "Invalid packet format" - return + return ErrorNetwork, "Invalid packet format" } |