Skip to content

Commit

Permalink
Optimized object label function performance
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Jan 4, 2022
1 parent 9d28149 commit 1399a6f
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions modules/engine/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,26 @@ func (o *Object) DN() string {
return o.OneAttrString(DistinguishedName)
}

var labelattrs = []Attribute{
LDAPDisplayName,
DisplayName,
Name,
DownLevelLogonName,
SAMAccountName,
Description,
DistinguishedName,
ObjectGUID,
ObjectSid,
}

func (o *Object) Label() string {
return util.Default(
o.OneAttrString(LDAPDisplayName),
o.OneAttrString(DisplayName),
o.OneAttrString(Name),
o.OneAttrString(DownLevelLogonName),
o.OneAttrString(SAMAccountName),
o.OneAttrString(Description),
o.OneAttrString(DistinguishedName),
o.OneAttrString(ObjectGUID),
o.OneAttrString(ObjectSid),
)
for _, attr := range labelattrs {
val := o.OneAttrString(attr)
if val != "" {
return val
}
}
return fmt.Sprintf("OBJ %v", o)
}

func (o *Object) Type() ObjectType {
Expand Down Expand Up @@ -329,7 +337,7 @@ func (o *Object) Type() ObjectType {
o.objecttype = ObjectTypeComputer
case "Group-Policy-Container":
o.objecttype = ObjectTypeGroupPolicyContainer
case "Domain Trust":
case "Trusted-Domain":
o.objecttype = ObjectTypeTrust
case "Attribute-Schema":
o.objecttype = ObjectTypeAttributeSchema
Expand Down

0 comments on commit 1399a6f

Please sign in to comment.