From f9d5abcccb4fc5fd04412aac0fdc85ffb7b5b0d6 Mon Sep 17 00:00:00 2001 From: Elan Yusuf Hakim Date: Wed, 1 Jun 2016 22:53:38 +0800 Subject: Fix issue where ManageDSAit control sent (#3) * Fix whitespace control value * Add strings package --- control.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'control.go') diff --git a/control.go b/control.go index 8376dd7..60fde91 100644 --- a/control.go +++ b/control.go @@ -5,6 +5,7 @@ package ldap import ( + "strings" "fmt" "github.com/nmcclain/asn1-ber" ) @@ -39,7 +40,9 @@ func (c *ControlString) Encode() *ber.Packet { if c.Criticality { packet.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimitive, ber.TagBoolean, c.Criticality, "Criticality")) } - packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, c.ControlValue, "Control Value")) + if strings.TrimSpace(c.ControlValue) != "" { + packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, c.ControlValue, "Control Value")) + } return packet } -- cgit v1.2.3