aboutsummaryrefslogtreecommitdiff
path: root/goldap/dn.go
blob: c622fd8b2640648eaa1eb5ecefdb3117df7760ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package message

import "fmt"

//
//        LDAPDN ::= LDAPString -- Constrained to <distinguishedName>
//                              -- [RFC4514]

func readLDAPDN(bytes *Bytes) (ret LDAPDN, err error) {
	var str LDAPString
	str, err = readLDAPString(bytes)
	if err != nil {
		err = LdapError{fmt.Sprintf("readLDAPDN:\n%s", err.Error())}
		return
	}
	ret = LDAPDN(str)
	return
}

func readTaggedLDAPDN(bytes *Bytes, class int, tag int) (ret LDAPDN, err error) {
	var ldapstring LDAPString
	ldapstring, err = readTaggedLDAPString(bytes, class, tag)
	if err != nil {
		err = LdapError{fmt.Sprintf("readTaggedLDAPDN:\n%s", err.Error())}
		return
	}
	// @TODO: check RFC4514
	ret = LDAPDN(ldapstring)
	return
}

func (l LDAPDN) Pointer() *LDAPDN { return &l }

func readRelativeLDAPDN(bytes *Bytes) (ret RelativeLDAPDN, err error) {
	var ldapstring LDAPString
	ldapstring, err = readLDAPString(bytes)
	if err != nil {
		err = LdapError{fmt.Sprintf("readRelativeLDAPDN:\n%s", err.Error())}
		return
	}
	// @TODO: check RFC4514
	ret = RelativeLDAPDN(ldapstring)
	return
}

func (l LDAPDN) write(bytes *Bytes) int {
	return LDAPString(l).write(bytes)
}

func (l LDAPDN) writeTagged(bytes *Bytes, class int, tag int) int {
	return LDAPString(l).writeTagged(bytes, class, tag)
}

func (l LDAPDN) size() int {
	return LDAPString(l).size()
}

func (l LDAPDN) sizeTagged(tag int) int {
	return LDAPString(l).sizeTagged(tag)
}