From caa65677a2c12692de1dd0c26980c1797abf91b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20GASCOU=20=28Podalirius=29?= Date: Sun, 29 Jun 2025 10:38:36 +0200 Subject: [PATCH] Added missing LDAP control ControlMicrosoftSDFlags to control.go --- v3/control.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/v3/control.go b/v3/control.go index e0dc0e1..7f5d76c 100644 --- a/v3/control.go +++ b/v3/control.go @@ -444,6 +444,42 @@ func NewControlMicrosoftNotification() *ControlMicrosoftNotification { return &ControlMicrosoftNotification{} } +type ControlMicrosoftSDFlags struct { + Criticality bool + ControlValue int32 +} + +func (c *ControlMicrosoftSDFlags) GetControlType() string { + // Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3888c2b7-35b9-45b7-afeb-b772aa932dd0 + return ControlTypeMicrosoftSDFlags +} + +func (c *ControlMicrosoftSDFlags) Encode() *ber.Packet { + packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control") + packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeMicrosoftSDFlags, "Control Type ("+ControlTypeMap[ControlTypeMicrosoftSDFlags]+")")) + if c.Criticality { + packet.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimitive, ber.TagBoolean, c.Criticality, "Criticality")) + } + p2 := ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, nil, "Control Value(SDFlags)") + seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "SDFlags") + seq.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, c.ControlValue, "Flags")) + p2.AppendChild(seq) + packet.AppendChild(p2) + return packet +} + +func (c *ControlMicrosoftSDFlags) String() string { + return fmt.Sprintf( + "Control Type: %s (%q)", + ControlTypeMap[ControlTypeMicrosoftSDFlags], + ControlTypeMicrosoftSDFlags) +} + +// NewControlMicrosoftSDFlags returns a ControlMicrosoftSDFlags control +func NewControlMicrosoftSDFlags() *ControlMicrosoftSDFlags { + return &ControlMicrosoftSDFlags{} +} + // ControlMicrosoftShowDeleted implements the control described in https://msdn.microsoft.com/en-us/library/aa366989(v=vs.85).aspx type ControlMicrosoftShowDeleted struct{}