Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return referrals for modify operation #375

Merged
merged 6 commits into from
Jun 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: add anti-panic guards
  • Loading branch information
james-d-elliott committed Apr 30, 2022
commit a78ea342c6b0cdeb20e5616e471a9517d36feb67
11 changes: 8 additions & 3 deletions modify.go
Original file line number Diff line number Diff line change
@@ -161,10 +161,15 @@ func (l *Conn) ModifyWithResult(modifyRequest *ModifyRequest) (*ModifyResult, er
case ApplicationModifyResponse:
err := GetLDAPError(packet)
if err != nil {
if IsErrorWithCode(err, LDAPResultReferral) {
if IsErrorWithCode(err, LDAPResultReferral) && len(packet.Children) >= 2 {
for _, child := range packet.Children[1].Children {
if child.Tag == 3 {
result.Referral = child.Children[0].Value.(string)
if child.Tag == 3 && len(child.Children) >= 1 {
referral, ok := child.Children[0].Value.(string)
if !ok {
continue
}

result.Referral = referral
}
}
}
12 changes: 9 additions & 3 deletions passwdmodify.go
Original file line number Diff line number Diff line change
@@ -97,13 +97,19 @@ func (l *Conn) PasswordModify(passwordModifyRequest *PasswordModifyRequest) (*Pa
if packet.Children[1].Tag == ApplicationExtendedResponse {
err := GetLDAPError(packet)
if err != nil {
if IsErrorWithCode(err, LDAPResultReferral) {
if IsErrorWithCode(err, LDAPResultReferral) && len(packet.Children) >= 2 {
for _, child := range packet.Children[1].Children {
if child.Tag == 3 {
result.Referral = child.Children[0].Value.(string)
if child.Tag == 3 && len(child.Children) >= 1 {
referral, ok := child.Children[0].Value.(string)
if !ok {
continue
}

result.Referral = referral
}
}
}

return result, err
}
} else {
11 changes: 8 additions & 3 deletions v3/modify.go
Original file line number Diff line number Diff line change
@@ -161,10 +161,15 @@ func (l *Conn) ModifyWithResult(modifyRequest *ModifyRequest) (*ModifyResult, er
case ApplicationModifyResponse:
err := GetLDAPError(packet)
if err != nil {
if IsErrorWithCode(err, LDAPResultReferral) {
if IsErrorWithCode(err, LDAPResultReferral) && len(packet.Children) >= 2 {
for _, child := range packet.Children[1].Children {
if child.Tag == 3 {
result.Referral = child.Children[0].Value.(string)
if child.Tag == 3 && len(child.Children) >= 1 {
referral, ok := child.Children[0].Value.(string)
if !ok {
continue
}

result.Referral = referral
}
}
}
12 changes: 9 additions & 3 deletions v3/passwdmodify.go
Original file line number Diff line number Diff line change
@@ -97,13 +97,19 @@ func (l *Conn) PasswordModify(passwordModifyRequest *PasswordModifyRequest) (*Pa
if packet.Children[1].Tag == ApplicationExtendedResponse {
err := GetLDAPError(packet)
if err != nil {
if IsErrorWithCode(err, LDAPResultReferral) {
if IsErrorWithCode(err, LDAPResultReferral) && len(packet.Children) >= 2 {
for _, child := range packet.Children[1].Children {
if child.Tag == 3 {
result.Referral = child.Children[0].Value.(string)
if child.Tag == 3 && len(child.Children) >= 1 {
referral, ok := child.Children[0].Value.(string)
if !ok {
continue
}

result.Referral = referral
}
}
}

return result, err
}
} else {