Skip to content

Conversation

@draeron
Copy link

@draeron draeron commented Apr 30, 2019

Fix for #216

Copy link
Member

@johnweldon johnweldon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @draeron for finding this issue and proposing this change. While reviewing I found there was a deeper issue caused by a careless merge on my part previously.

If you'd like to revise your PR as I suggest, I can merge it - otherwise, I'll make the changes I describe in a separate PR.

@@ -0,0 +1,5 @@
module go-ldap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm generally in favor of adding go.(mod|sum) to the project, but let's do it in a separate PR

}
if len(packet.Children) == 3 {
return addControlDescriptions(packet.Children[2])
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a subtle issue here, partially introduced by PR #191 where the getLDAPResultCode function was replaced by GetLDAPError - the semantics changed subtly with this PR, and I missed the implications when I merged it.

Even if there is no error, the original intent of this function is to add Descriptions; I think this may be a more useful change:

diff --git ldap.go ldap.go
index d766667..831fa02 100644
--- ldap.go
+++ ldap.go
@@ -270,10 +270,13 @@ func addRequestDescriptions(packet *ber.Packet) error {
 }
 
 func addDefaultLDAPResponseDescriptions(packet *ber.Packet) error {
-       err := GetLDAPError(packet)
-       packet.Children[1].Children[0].Description = "Result Code (" + LDAPResultCodeMap[err.(*Error).ResultCode] + ")"
-       packet.Children[1].Children[1].Description = "Matched DN (" + err.(*Error).MatchedDN + ")"
-       packet.Children[1].Children[2].Description = "Error Message"
+       resultCode := uint16(LDAPResultSuccess)
+       if err := GetLDAPError(packet); err != nil {
+               resultCode = err.(*Error).ResultCode
+               packet.Children[1].Children[2].Description = "Error Message"
+       }
+       packet.Children[1].Children[0].Description = "Result Code (" + LDAPResultCodeMap[resultCode] + ")"
+       packet.Children[1].Children[1].Description = "Matched DN"
        if len(packet.Children[1].Children) > 3 {
                packet.Children[1].Children[3].Description = "Referral"
        }

I may need to find a good way to back out the previous PR that skews the original intent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any news here? I'm affected by this too. I don't mind to make another PR trying to address it and other possible occurrences of this same problem (If I find them).

@johnweldon
Copy link
Member

Feel free to make a new PR if this isn't resolved by other more recent changes.

@johnweldon johnweldon closed this Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants