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/modify_dn_request.go | |
parent | a53641e773730ba171df2602c8d199968d6e6447 (diff) | |
download | bottin-477d7014edc787ba9a977acd19fcbfc55531768b.tar.gz bottin-477d7014edc787ba9a977acd19fcbfc55531768b.zip |
Vendor goldap
Diffstat (limited to 'goldap/modify_dn_request.go')
-rw-r--r-- | goldap/modify_dn_request.go | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/goldap/modify_dn_request.go b/goldap/modify_dn_request.go new file mode 100644 index 0000000..8c4ab75 --- /dev/null +++ b/goldap/modify_dn_request.go @@ -0,0 +1,87 @@ +package message + +import "fmt" + +// +// ModifyDNRequest ::= [APPLICATION 12] SEQUENCE { +// entry LDAPDN, +// newrdn RelativeLDAPDN, +// deleteoldrdn BOOLEAN, +// newSuperior [0] LDAPDN OPTIONAL } +func readModifyDNRequest(bytes *Bytes) (ret ModifyDNRequest, err error) { + err = bytes.ReadSubBytes(classApplication, TagModifyDNRequest, ret.readComponents) + if err != nil { + err = LdapError{fmt.Sprintf("readModifyDNRequest:\n%s", err.Error())} + return + } + return +} +func (req *ModifyDNRequest) readComponents(bytes *Bytes) (err error) { + req.entry, err = readLDAPDN(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + req.newrdn, err = readRelativeLDAPDN(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + req.deleteoldrdn, err = readBOOLEAN(bytes) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + if bytes.HasMoreData() { + var tag TagAndLength + tag, err = bytes.PreviewTagAndLength() + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + if tag.Tag == TagModifyDNRequestNewSuperior { + var ldapdn LDAPDN + ldapdn, err = readTaggedLDAPDN(bytes, classContextSpecific, TagModifyDNRequestNewSuperior) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + req.newSuperior = ldapdn.Pointer() + } + } + return +} + +// +// ModifyDNRequest ::= [APPLICATION 12] SEQUENCE { +// entry LDAPDN, +// newrdn RelativeLDAPDN, +// deleteoldrdn BOOLEAN, +// newSuperior [0] LDAPDN OPTIONAL } +func (m ModifyDNRequest) write(bytes *Bytes) (size int) { + if m.newSuperior != nil { + size += m.newSuperior.writeTagged(bytes, classContextSpecific, TagModifyDNRequestNewSuperior) + } + size += m.deleteoldrdn.write(bytes) + size += m.newrdn.write(bytes) + size += m.entry.write(bytes) + size += bytes.WriteTagAndLength(classApplication, isCompound, TagModifyDNRequest, size) + return +} + +// +// ModifyDNRequest ::= [APPLICATION 12] SEQUENCE { +// entry LDAPDN, +// newrdn RelativeLDAPDN, +// deleteoldrdn BOOLEAN, +// newSuperior [0] LDAPDN OPTIONAL } +func (m ModifyDNRequest) size() (size int) { + size += m.entry.size() + size += m.newrdn.size() + size += m.deleteoldrdn.size() + if m.newSuperior != nil { + size += m.newSuperior.sizeTagged(TagModifyDNRequestNewSuperior) + } + size += sizeTagAndLength(TagModifyDNRequest, size) + return +} |