Skip to content

Commit 06d7bd9

Browse files
authored
Added missing LDAP control ControlMicrosoftSDFlags to control.go (#560)
1 parent bab0be5 commit 06d7bd9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

v3/control.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,42 @@ func NewControlMicrosoftNotification() *ControlMicrosoftNotification {
444444
return &ControlMicrosoftNotification{}
445445
}
446446

447+
type ControlMicrosoftSDFlags struct {
448+
Criticality bool
449+
ControlValue int32
450+
}
451+
452+
func (c *ControlMicrosoftSDFlags) GetControlType() string {
453+
// Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3888c2b7-35b9-45b7-afeb-b772aa932dd0
454+
return ControlTypeMicrosoftSDFlags
455+
}
456+
457+
func (c *ControlMicrosoftSDFlags) Encode() *ber.Packet {
458+
packet := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "Control")
459+
packet.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, ControlTypeMicrosoftSDFlags, "Control Type ("+ControlTypeMap[ControlTypeMicrosoftSDFlags]+")"))
460+
if c.Criticality {
461+
packet.AppendChild(ber.NewBoolean(ber.ClassUniversal, ber.TypePrimitive, ber.TagBoolean, c.Criticality, "Criticality"))
462+
}
463+
p2 := ber.Encode(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, nil, "Control Value(SDFlags)")
464+
seq := ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "SDFlags")
465+
seq.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, c.ControlValue, "Flags"))
466+
p2.AppendChild(seq)
467+
packet.AppendChild(p2)
468+
return packet
469+
}
470+
471+
func (c *ControlMicrosoftSDFlags) String() string {
472+
return fmt.Sprintf(
473+
"Control Type: %s (%q)",
474+
ControlTypeMap[ControlTypeMicrosoftSDFlags],
475+
ControlTypeMicrosoftSDFlags)
476+
}
477+
478+
// NewControlMicrosoftSDFlags returns a ControlMicrosoftSDFlags control
479+
func NewControlMicrosoftSDFlags() *ControlMicrosoftSDFlags {
480+
return &ControlMicrosoftSDFlags{}
481+
}
482+
447483
// ControlMicrosoftShowDeleted implements the control described in https://msdn.microsoft.com/en-us/library/aa366989(v=vs.85).aspx
448484
type ControlMicrosoftShowDeleted struct{}
449485

0 commit comments

Comments
 (0)