diff options
author | ned <ned@appliedtrust.com> | 2014-11-23 20:03:05 +0100 |
---|---|---|
committer | ned <ned@appliedtrust.com> | 2014-11-23 20:03:05 +0100 |
commit | c43d537d5bb0eeb491153b00cdefcb54a6178187 (patch) | |
tree | 45187fde4a720d3f53d13ec45ac4fea8e27356e4 /control.go | |
parent | LDAP server support (diff) | |
download | ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.gz ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.bz2 ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.lz ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.xz ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.tar.zst ldap-c43d537d5bb0eeb491153b00cdefcb54a6178187.zip |
Diffstat (limited to 'control.go')
-rw-r--r-- | control.go | 62 |
1 files changed, 31 insertions, 31 deletions
@@ -6,7 +6,6 @@ package ldap import ( "fmt" - "github.com/nmcclain/asn1-ber" ) @@ -99,40 +98,41 @@ func FindControl(controls []Control, controlType string) Control { func DecodeControl(packet *ber.Packet) Control { ControlType := packet.Children[0].Value.(string) - Criticality := false - packet.Children[0].Description = "Control Type (" + ControlTypeMap[ControlType] + ")" - value := packet.Children[1] - if len(packet.Children) == 3 { - value = packet.Children[2] - packet.Children[1].Description = "Criticality" - Criticality = packet.Children[1].Value.(bool) - } + c := new(ControlString) + c.ControlType = ControlType + c.Criticality = false + + if len(packet.Children) > 1 { + value := packet.Children[1] + if len(packet.Children) == 3 { + value = packet.Children[2] + packet.Children[1].Description = "Criticality" + c.Criticality = packet.Children[1].Value.(bool) + } - value.Description = "Control Value" - switch ControlType { - case ControlTypePaging: - value.Description += " (Paging)" - c := new(ControlPaging) - if value.Value != nil { - valueChildren := ber.DecodePacket(value.Data.Bytes()) - value.Data.Truncate(0) - value.Value = nil - value.AppendChild(valueChildren) + value.Description = "Control Value" + switch ControlType { + case ControlTypePaging: + value.Description += " (Paging)" + c := new(ControlPaging) + if value.Value != nil { + valueChildren := ber.DecodePacket(value.Data.Bytes()) + value.Data.Truncate(0) + value.Value = nil + value.AppendChild(valueChildren) + } + value = value.Children[0] + value.Description = "Search Control Value" + value.Children[0].Description = "Paging Size" + value.Children[1].Description = "Cookie" + c.PagingSize = uint32(value.Children[0].Value.(uint64)) + c.Cookie = value.Children[1].Data.Bytes() + value.Children[1].Value = c.Cookie + return c } - value = value.Children[0] - value.Description = "Search Control Value" - value.Children[0].Description = "Paging Size" - value.Children[1].Description = "Cookie" - c.PagingSize = uint32(value.Children[0].Value.(uint64)) - c.Cookie = value.Children[1].Data.Bytes() - value.Children[1].Value = c.Cookie - return c + c.ControlValue = value.Value.(string) } - c := new(ControlString) - c.ControlType = ControlType - c.Criticality = Criticality - c.ControlValue = value.Value.(string) return c } |