forked from chfuchte/TypeScript-Window-UserList
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.ts
More file actions
52 lines (40 loc) · 1.6 KB
/
User.ts
File metadata and controls
52 lines (40 loc) · 1.6 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
42
43
44
45
46
47
48
49
50
51
52
import runCmd from './runCmd';
export default class User {
username: string | any
domain: any
name: any
class: any
ready: boolean | any
constructor(username: any, domain: any) {
this.username = username;
this.domain = domain;
this.name = "";
this.class = "";
this.ready = false;
}
async parseData() {
const name = await BenutzerName(this.username, this.domain) ?? null;
const userClass = await BenutzerKlasse(this.username, this.domain) ?? null;
this.name = name;
this.class = userClass;
this.ready = true;
}
}
async function BenutzerKlasse(username: any, domain: any) {
const output: any = await runCmd("net", `user ${username}${domain ? " /domain" : ""}`);
const outputLines = output.split("\n").map((line: any) => line.trim());
const userinfo = outputLines.find((line: any) => line.startsWith("Globale Gruppenmitgliedschaften"));
if (!userinfo || userinfo.substring("Globale Gruppenmitgliedschaften".length).trim() == "*Kein") {
return null;
}
return userinfo.substring("Globale Gruppenmitgliedschaften".length).trim();
}
async function BenutzerName(username: any, domain: any) {
const output: any = await runCmd("net", `user ${username} ${domain ? " /domain" : ""}`);
const outputLines: string[] = output.split("\n").map((line: string) => line.trim());
const userinfo = outputLines.find((line: string) => line.startsWith("Vollst�ndiger Name"));
if (!userinfo) {
return null;
}
return userinfo.substring("Vollst�ndiger Name".length).trim();
}