-
Notifications
You must be signed in to change notification settings - Fork 0
/
naming-context.ts
106 lines (96 loc) · 3.03 KB
/
naming-context.ts
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
99
100
101
102
103
104
105
106
import type { Client } from "ldap-ts-client";
import type { Logger } from "fast-node-logger";
type GetNamingContextsFnInput = {
client: Client;
options?: { logger?: Logger };
};
/** get base DNs from RootDSE
* - A multiple-valued attribute that contains the distinguished names for all naming contexts stored on this directory server. By default, a Windows 2000 domain controller contains at least three naming contexts: Schema, Configuration, and one for the domain of which the server is a member.
*/
export async function getNamingContexts({
client,
options,
}: GetNamingContextsFnInput): Promise<string[]> {
options?.logger?.trace("getNamingContexts()");
const data = await client.queryAttributes({
attributes: ["namingContexts"],
base: "",
options: {
filter: "(&(objectClass=*))",
scope: "base",
},
});
return data[0].namingContexts as string[];
}
/** get DefaultNamingContext from RootDSE
* - Contains the distinguished name for the domain of which this directory server is a member.
*/
export async function getDefaultNamingContext({
options,
client,
}: GetNamingContextsFnInput): Promise<string> {
options?.logger?.trace("getDefaultNamingContext()");
const data = await client.queryAttributes({
attributes: ["defaultNamingContext"],
base: "",
options: {
filter: "(&(objectClass=*))",
scope: "base",
},
});
return data[0].defaultNamingContext as string;
}
/** get SchemaNamingContext from RootDSE
* - Contains the distinguished name for the schema container.
*/
export async function getSchemaNamingContext({
options,
client,
}: GetNamingContextsFnInput): Promise<string> {
options?.logger?.trace("getSchemaNamingContext()");
const data = await client.queryAttributes({
attributes: ["schemaNamingContext"],
base: "",
options: {
filter: "(&(objectClass=*))",
scope: "base",
},
});
return data[0].schemaNamingContext as string;
}
/** get rootDomainNamingContext from RootDSE
* - Contains the distinguished name for the first domain in the forest that contains the domain of which this directory server is a member.
*/
export async function getRootNamingContext({
options,
client,
}: GetNamingContextsFnInput): Promise<string> {
options?.logger?.trace("getSchemaNamingContext()");
const data = await client.queryAttributes({
attributes: ["rootDomainNamingContext"],
base: "",
options: {
filter: "(&(objectClass=*))",
scope: "base",
},
});
return data[0].rootDomainNamingContext as string;
}
/** get configurationNamingContext from RootDSE
* - DN of the Configuration NamingContext
*/
export async function getConfigurationNamingContext({
options,
client,
}: GetNamingContextsFnInput): Promise<string> {
options?.logger?.trace("getSchemaNamingContext()");
const data = await client.queryAttributes({
attributes: ["configurationNamingContext"],
base: "",
options: {
filter: "(&(objectClass=*))",
scope: "base",
},
});
return data[0].configurationNamingContext as string;
}