diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-09-16 13:41:01 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2021-09-16 13:41:01 +0200 |
commit | 477d7014edc787ba9a977acd19fcbfc55531768b (patch) | |
tree | ac8b65be8634fa9526cd727da60893244d11e88a /goldap/search_result_entry.go | |
parent | a53641e773730ba171df2602c8d199968d6e6447 (diff) | |
download | bottin-477d7014edc787ba9a977acd19fcbfc55531768b.tar.gz bottin-477d7014edc787ba9a977acd19fcbfc55531768b.zip |
Vendor goldap
Diffstat (limited to 'goldap/search_result_entry.go')
-rw-r--r-- | goldap/search_result_entry.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/goldap/search_result_entry.go b/goldap/search_result_entry.go new file mode 100644 index 0000000..05d8e10 --- /dev/null +++ b/goldap/search_result_entry.go @@ -0,0 +1,58 @@ +package message + +import "fmt" + +// +// SearchResultEntry ::= [APPLICATION 4] SEQUENCE { +// objectName LDAPDN, +// attributes PartialAttributeList } +func readSearchResultEntry(bytes *Bytes) (searchresultentry SearchResultEntry, err error) { + err = bytes.ReadSubBytes(classApplication, TagSearchResultEntry, searchresultentry.readComponents) + if err != nil { + err = LdapError{fmt.Sprintf("readSearchResultEntry:\n%s", err.Error())} + return + } + return +} +func (searchresultentry *SearchResultEntry) readComponents(bytes *Bytes) (err error) { + searchresultentry.objectName, err = readLDAPDN(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + searchresultentry.attributes, err = readPartialAttributeList(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + return +} + +// +// SearchResultEntry ::= [APPLICATION 4] SEQUENCE { +// objectName LDAPDN, +// attributes PartialAttributeList } +func (s SearchResultEntry) write(bytes *Bytes) (size int) { + size += s.attributes.write(bytes) + size += s.objectName.write(bytes) + size += bytes.WriteTagAndLength(classApplication, isCompound, TagSearchResultEntry, size) + return +} + +// +// SearchResultEntry ::= [APPLICATION 4] SEQUENCE { +// objectName LDAPDN, +// attributes PartialAttributeList } +func (s SearchResultEntry) size() (size int) { + size += s.objectName.size() + size += s.attributes.size() + size += sizeTagAndLength(tagSequence, size) + return +} +func (s *SearchResultEntry) SetObjectName(on string) { + s.objectName = LDAPDN(on) +} +func (s *SearchResultEntry) AddAttribute(name AttributeDescription, values ...AttributeValue) { + var ea = PartialAttribute{type_: name, vals: values} + s.attributes.add(ea) +} |