-
Notifications
You must be signed in to change notification settings - Fork 79
/
dumpRootDSE.go
98 lines (92 loc) · 2.43 KB
/
dumpRootDSE.go
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"github.com/lkarlslund/ldap/v3"
)
var defaultDumpAttrs = []string{
"configurationNamingContext",
"currentTime",
"defaultNamingContext",
"dNSHostName",
"dsSchemaAttrCount",
"dsSchemaClassCount",
"dsSchemaPrefixCount",
"dsServiceName",
"highestCommittedUSN",
"isGlobalCatalogReady",
"isSynchronized",
"ldapServiceName",
"namingContexts",
"netlogon",
"pendingPropagations",
"rootDomainNamingContext",
"schemaNamingContext",
"serverName",
"subschemaSubentry",
"supportedCapabilities",
"supportedControl",
"supportedLDAPPolicies",
"supportedLDAPVersion",
"supportedSASLMechanisms",
"domainControllerFunctionality",
"domainFunctionality",
"forestFunctionality",
"msDS-ReplAllInboundNeighbors",
"msDS-ReplAllOutboundNeighbors",
"msDS-ReplConnectionFailures",
"msDS-ReplLinkFailures",
"msDS-ReplPendingOps",
"msDS-ReplQueueStatistics",
"msDS-TopQuotaUsage",
"supportedConfigurableSettings",
"supportedExtension",
"validFSMOs",
"dsaVersionString",
"msDS-PortLDAP",
"msDS-PortSSL",
"msDS-PrincipalName",
"serviceAccountInfo",
"spnRegistrationResult",
"tokenGroups",
"usnAtRifm",
"approximateHighestInternalObjectID",
"databaseGuid",
"schemaIndexUpdateState",
"dumpLdapNotifications",
"msDS-ProcessLinksOperations",
"msDS-SegmentCacheInfo",
"msDS-ThreadStates",
"ConfigurableSettingsEffective",
"LDAPPoliciesEffective",
"msDS-ArenaInfo",
"msDS-Anchor",
"msDS-PrefixTable",
"msDS-SupportedRootDSEAttributes",
"msDS-SupportedRootDSEModifications",
}
func dumpRootDSE(conn *ldap.Conn) (map[string][]string, error) {
result := make(map[string][]string)
// See if we can ask the server what attributes it knows about
probeAttrs := getRootDSEAttribute(conn, "msDS-SupportedRootDSEAttributes")
if len(probeAttrs) == 0 {
probeAttrs = defaultDumpAttrs
}
// Extract what we can
for _, attribute := range probeAttrs {
result[attribute] = getRootDSEAttribute(conn, attribute)
}
return result, nil
}
func getRootDSEAttribute(conn *ldap.Conn, attribute string) []string {
request := ldap.NewSearchRequest(
"", // The base dn to search
ldap.ScopeBaseObject, ldap.NeverDerefAliases, 0, 0, false,
"(objectClass=*)", // The filter to apply
[]string{attribute}, // A list attributes to retrieve
nil,
)
response, err := conn.Search(request)
if err == nil && len(response.Entries) == 1 && len(response.Entries[0].Attributes) == 1 {
return response.Entries[0].Attributes[0].Values
}
return nil
}