diff --git a/error.go b/error.go index 53c6d622..0014ffe2 100644 --- a/error.go +++ b/error.go @@ -220,7 +220,7 @@ func GetLDAPError(packet *ber.Packet) error { return &Error{ ResultCode: resultCode, MatchedDN: response.Children[1].Value.(string), - Err: fmt.Errorf("%s", response.Children[2].Value.(string)), + Err: fmt.Errorf("%v", response.Children[2].Value), Packet: packet, } } diff --git a/search.go b/search.go index b5550ba6..62be1054 100644 --- a/search.go +++ b/search.go @@ -579,9 +579,13 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { return result, ErrSizeLimitExceeded } + attr := make([]*ber.Packet, 0) + if len(packet.Children[1].Children) > 1 { + attr = packet.Children[1].Children[1].Children + } entry := &Entry{ DN: packet.Children[1].Children[0].Value.(string), - Attributes: unpackAttributes(packet.Children[1].Children[1].Children), + Attributes: unpackAttributes(attr), } result.Entries = append(result.Entries, entry) case 5: diff --git a/v3/error.go b/v3/error.go index 53c6d622..0014ffe2 100644 --- a/v3/error.go +++ b/v3/error.go @@ -220,7 +220,7 @@ func GetLDAPError(packet *ber.Packet) error { return &Error{ ResultCode: resultCode, MatchedDN: response.Children[1].Value.(string), - Err: fmt.Errorf("%s", response.Children[2].Value.(string)), + Err: fmt.Errorf("%v", response.Children[2].Value), Packet: packet, } } diff --git a/v3/search.go b/v3/search.go index b5550ba6..62be1054 100644 --- a/v3/search.go +++ b/v3/search.go @@ -579,9 +579,13 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { return result, ErrSizeLimitExceeded } + attr := make([]*ber.Packet, 0) + if len(packet.Children[1].Children) > 1 { + attr = packet.Children[1].Children[1].Children + } entry := &Entry{ DN: packet.Children[1].Children[0].Value.(string), - Attributes: unpackAttributes(packet.Children[1].Children[1].Children), + Attributes: unpackAttributes(attr), } result.Entries = append(result.Entries, entry) case 5: