@@ -77,6 +77,17 @@ func (e *Entry) GetAttributeValues(attribute string) []string {
77
77
return []string {}
78
78
}
79
79
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
+
80
91
// GetRawAttributeValues returns the byte values for the named attribute, or an empty list
81
92
func (e * Entry ) GetRawAttributeValues (attribute string ) [][]byte {
82
93
for _ , attr := range e .Attributes {
@@ -87,6 +98,16 @@ func (e *Entry) GetRawAttributeValues(attribute string) [][]byte {
87
98
return [][]byte {}
88
99
}
89
100
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
+
90
111
// GetAttributeValue returns the first value for the named attribute, or ""
91
112
func (e * Entry ) GetAttributeValue (attribute string ) string {
92
113
values := e .GetAttributeValues (attribute )
@@ -96,6 +117,16 @@ func (e *Entry) GetAttributeValue(attribute string) string {
96
117
return values [0 ]
97
118
}
98
119
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
+
99
130
// GetRawAttributeValue returns the first value for the named attribute, or an empty slice
100
131
func (e * Entry ) GetRawAttributeValue (attribute string ) []byte {
101
132
values := e .GetRawAttributeValues (attribute )
@@ -105,6 +136,15 @@ func (e *Entry) GetRawAttributeValue(attribute string) []byte {
105
136
return values [0 ]
106
137
}
107
138
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
+
108
148
// Print outputs a human-readable description
109
149
func (e * Entry ) Print () {
110
150
fmt .Printf ("DN: %s\n " , e .DN )
0 commit comments