forked from go-ldap/ldap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrootdse.go
More file actions
41 lines (37 loc) · 1.02 KB
/
rootdse.go
File metadata and controls
41 lines (37 loc) · 1.02 KB
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
package ldap
import (
"errors"
)
// ROOTDSE common attributes
const (
RootDSEdefaultNamingContext = "defaultNamingContext"
RootDSEdnsHostName = "dnsHostName"
RootDSEsupportedSASLMechanisms = "supportedSASLMechanisms"
RootDSEldapServiceName = "ldapServiceName"
RootDSEhighestCommittedUSN = "highestCommittedUSN"
RootDSEsubschemaSubentry = "subschemaSubentry"
RootDSEschemaNamingContext = "schemaNamingContext"
RootDSEsupportedControl = "supportedControl"
)
// RootDSE allows to retrieve the RootDSE entry, returning the provided attributes
func (conn *Conn) RootDSE(fields ...string) (*Entry, error) {
if len(fields) == 0 {
fields = nil
}
// scan root DSE
search := NewSearchRequest(
"",
ScopeBaseObject, NeverDerefAliases, 0, 0, false,
"(objectclass=*)",
fields,
nil)
res, err := conn.Search(search)
if err != nil {
return nil, err
}
if len(res.Entries) != 1 {
return nil, errors.New("Cannot get RootDSE")
}
rootEntry := res.Entries[0]
return rootEntry, nil
}