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/bind_response.go | |
parent | a53641e773730ba171df2602c8d199968d6e6447 (diff) | |
download | bottin-477d7014edc787ba9a977acd19fcbfc55531768b.tar.gz bottin-477d7014edc787ba9a977acd19fcbfc55531768b.zip |
Vendor goldap
Diffstat (limited to 'goldap/bind_response.go')
-rw-r--r-- | goldap/bind_response.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/goldap/bind_response.go b/goldap/bind_response.go new file mode 100644 index 0000000..2d9db30 --- /dev/null +++ b/goldap/bind_response.go @@ -0,0 +1,56 @@ +package message + +import "fmt" + +// BindResponse ::= [APPLICATION 1] SEQUENCE { +// COMPONENTS OF LDAPResult, +// serverSaslCreds [7] OCTET STRING OPTIONAL } + +func readBindResponse(bytes *Bytes) (bindresponse BindResponse, err error) { + err = bytes.ReadSubBytes(classApplication, TagBindResponse, bindresponse.readComponents) + if err != nil { + err = LdapError{fmt.Sprintf("readBindResponse:\n%s", err.Error())} + return + } + return +} + +func (response *BindResponse) readComponents(bytes *Bytes) (err error) { + response.LDAPResult.readComponents(bytes) + 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 == TagBindResponseServerSaslCreds { + var serverSaslCreds OCTETSTRING + serverSaslCreds, err = readTaggedOCTETSTRING(bytes, classContextSpecific, TagBindResponseServerSaslCreds) + if err != nil { + err = LdapError{fmt.Sprintf("readComponents:\n%s", err.Error())} + return + } + response.serverSaslCreds = serverSaslCreds.Pointer() + } + } + return +} + +func (response BindResponse) write(bytes *Bytes) (size int) { + if response.serverSaslCreds != nil { + size += response.serverSaslCreds.writeTagged(bytes, classContextSpecific, TagBindResponseServerSaslCreds) + } + size += response.LDAPResult.writeComponents(bytes) + size += bytes.WriteTagAndLength(classApplication, isCompound, TagBindResponse, size) + return +} + +func (response BindResponse) size() (size int) { + if response.serverSaslCreds != nil { + size += response.serverSaslCreds.sizeTagged(TagBindResponseServerSaslCreds) + } + size += response.LDAPResult.sizeComponents() + size += sizeTagAndLength(TagBindResponse, size) + return +} |