@@ -238,6 +238,22 @@ func ParseUACFlags(uacInt int) []string {
238238 return uacFlagsList
239239}
240240
241+ func parseBitFlags (v uint32 , flagMap map [uint32 ]string ) []string {
242+ keys := make ([]uint32 , 0 , len (flagMap ))
243+ for k := range flagMap {
244+ keys = append (keys , k )
245+ }
246+ sort .Slice (keys , func (i , j int ) bool { return keys [i ] < keys [j ] })
247+
248+ var result []string
249+ for _ , bit := range keys {
250+ if v & bit != 0 {
251+ result = append (result , flagMap [bit ])
252+ }
253+ }
254+ return result
255+ }
256+
241257func ParseSystemFlags (v uint32 ) []string {
242258 sysFlagKeys := make ([]uint32 , 0 )
243259 for k := range SystemFlags {
@@ -300,27 +316,52 @@ func FormatLDAPAttribute(attr *ldap.EntryAttribute, timeFormat string, timeOffse
300316 }
301317
302318 /* Special parsing for bitset expansions */
303- if attr .Name == "userAccountControl" || attr .Name == "systemFlags" {
304- switch attr .Name {
305- case "userAccountControl" :
306- uacInt , err := strconv .Atoi (attr .Values [0 ])
307- if err == nil {
308- formattedEntries = ParseUACFlags (uacInt )
319+ bitsetAttrs := map [string ]func (string ) []string {
320+ "userAccountControl" : func (v string ) []string {
321+ i , err := strconv .Atoi (v )
322+ if err != nil {
323+ return nil
309324 }
310- case "systemFlags" :
311- intValue , err := strconv .ParseInt (attr .Values [0 ], 10 , 64 )
312- if err == nil {
313- formattedEntries = ParseSystemFlags (uint32 (intValue ))
325+ return ParseUACFlags (i )
326+ },
327+ "systemFlags" : func (v string ) []string {
328+ i , err := strconv .ParseInt (v , 10 , 64 )
329+ if err != nil {
330+ return nil
314331 }
315- }
332+ return ParseSystemFlags (uint32 (i ))
333+ },
334+ "trustAttributes" : func (v string ) []string {
335+ i , err := strconv .ParseUint (v , 10 , 32 )
336+ if err != nil {
337+ return nil
338+ }
339+ return parseBitFlags (uint32 (i ), TrustAttributeFlags )
340+ },
341+ "pwdProperties" : func (v string ) []string {
342+ i , err := strconv .ParseUint (v , 10 , 32 )
343+ if err != nil {
344+ return nil
345+ }
346+ return parseBitFlags (uint32 (i ), PwdPropertiesFlags )
347+ },
348+ "searchFlags" : func (v string ) []string {
349+ i , err := strconv .ParseUint (v , 10 , 32 )
350+ if err != nil {
351+ return nil
352+ }
353+ return parseBitFlags (uint32 (i ), SearchFlagsMap )
354+ },
355+ }
316356
357+ if parseFn , ok := bitsetAttrs [attr .Name ]; ok {
358+ formattedEntries = parseFn (attr .Values [0 ])
317359 for _ , x := range formattedEntries {
318360 formattedAttrValues = append (formattedAttrValues , FormattedAttrValue {
319361 OriginalValue : attr .Values [0 ],
320362 FormattedValue : x ,
321363 })
322364 }
323-
324365 return FormattedAttr {formattedAttrValues }
325366 }
326367
@@ -329,9 +370,9 @@ func FormatLDAPAttribute(attr *ldap.EntryAttribute, timeFormat string, timeOffse
329370 // Format the value
330371 var formattedEntry string
331372 switch attr .Name {
332- case "objectSid" :
373+ case "objectSid" , "securityIdentifier" :
333374 formattedEntry = "SID{" + ConvertSID (hex .EncodeToString (attr .ByteValues [idx ])) + "}"
334- case "objectGUID" , "schemaIDGUID" :
375+ case "objectGUID" , "schemaIDGUID" , "attributeSecurityGUID" :
335376 formattedEntry = "GUID{" + ConvertGUID (hex .EncodeToString (attr .ByteValues [idx ])) + "}"
336377 case "whenCreated" , "whenChanged" :
337378 formattedEntry = FormatLDAPTime (val , timeFormat , timeOffset )
@@ -371,7 +412,7 @@ func FormatLDAPAttribute(attr *ldap.EntryAttribute, timeFormat string, timeOffse
371412 if ok {
372413 formattedEntry = instanceType
373414 }
374- case "logonHours" , "dSASignature" :
415+ case "logonHours" , "dSASignature" , "oMObjectClass" , "cACertificate" :
375416 formattedEntry = "HEX{" + hex .EncodeToString (attr .ByteValues [idx ]) + "}"
376417 case "msDS-MaximumPasswordAge" , "msDS-MinimumPasswordAge" , "msDS-LockoutDuration" , "msDS-LockoutObservationWindow" , "lockoutDuration" , "lockOutObservationWindow" , "maxPwdAge" , "minPwdAge" , "forceLogoff" , "msDS-UserTGTLifetime" , "msDS-ComputerTGTLifetime" , "msDS-ServiceTGTLifetime" :
377418 duration , err := ParseMSDuration (val )
0 commit comments