@@ -77,6 +77,17 @@ func (e *Entry) GetAttributeValues(attribute string) []string {
7777 return []string {}
7878}
7979
80+ // GetEqualFoldAttributeValues returns the values for the named attribute, or an
81+ // empty list. Attribute matching is done with strings.EqualFold.
82+ func (e * Entry ) GetEqualFoldAttributeValues (attribute string ) []string {
83+ for _ , attr := range e .Attributes {
84+ if strings .EqualFold (attribute , attr .Name ) {
85+ return attr .Values
86+ }
87+ }
88+ return []string {}
89+ }
90+
8091// GetRawAttributeValues returns the byte values for the named attribute, or an empty list
8192func (e * Entry ) GetRawAttributeValues (attribute string ) [][]byte {
8293 for _ , attr := range e .Attributes {
@@ -87,6 +98,16 @@ func (e *Entry) GetRawAttributeValues(attribute string) [][]byte {
8798 return [][]byte {}
8899}
89100
101+ // GetEqualFoldRawAttributeValues returns the byte values for the named attribute, or an empty list
102+ func (e * Entry ) GetEqualFoldRawAttributeValues (attribute string ) [][]byte {
103+ for _ , attr := range e .Attributes {
104+ if strings .EqualFold (attr .Name , attribute ) {
105+ return attr .ByteValues
106+ }
107+ }
108+ return [][]byte {}
109+ }
110+
90111// GetAttributeValue returns the first value for the named attribute, or ""
91112func (e * Entry ) GetAttributeValue (attribute string ) string {
92113 values := e .GetAttributeValues (attribute )
@@ -96,6 +117,16 @@ func (e *Entry) GetAttributeValue(attribute string) string {
96117 return values [0 ]
97118}
98119
120+ // GetEqualFoldAttributeValue returns the first value for the named attribute, or "".
121+ // Attribute comparison is done with strings.EqualFold.
122+ func (e * Entry ) GetEqualFoldAttributeValue (attribute string ) string {
123+ values := e .GetEqualFoldAttributeValues (attribute )
124+ if len (values ) == 0 {
125+ return ""
126+ }
127+ return values [0 ]
128+ }
129+
99130// GetRawAttributeValue returns the first value for the named attribute, or an empty slice
100131func (e * Entry ) GetRawAttributeValue (attribute string ) []byte {
101132 values := e .GetRawAttributeValues (attribute )
@@ -105,6 +136,15 @@ func (e *Entry) GetRawAttributeValue(attribute string) []byte {
105136 return values [0 ]
106137}
107138
139+ // GetEqualFoldRawAttributeValue returns the first value for the named attribute, or an empty slice
140+ func (e * Entry ) GetEqualFoldRawAttributeValue (attribute string ) []byte {
141+ values := e .GetEqualFoldRawAttributeValues (attribute )
142+ if len (values ) == 0 {
143+ return []byte {}
144+ }
145+ return values [0 ]
146+ }
147+
108148// Print outputs a human-readable description
109149func (e * Entry ) Print () {
110150 fmt .Printf ("DN: %s\n " , e .DN )
0 commit comments