Skip to content

Commit 5964275

Browse files
committed
fix
1 parent df44cf9 commit 5964275

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

http/keycloak.http

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Accept: application/json
3636

3737
###
3838

39-
@targetOu = 4AHIF
4039
@max = 3000
4140
### Benutzer abrufen mit Fortschrittsausgabe + reiner Namensliste
4241
GET {{keycloakUrl}}/admin/realms/{{realm}}/users?max={{max}}
@@ -66,7 +65,9 @@ Accept: application/json
6665

6766
console.log(`==> Abruf fertig: ${users.length} Benutzer (${((Date.now()-t0)/1000).toFixed(1)} s)`);
6867

69-
const wantOu = "4AHIF";
68+
// Filterfunktion für OU ----------
69+
const wantOu = "4CHIF";
70+
// --------------------------------
7071
function inTargetOu(u) {
7172
if (!wantOu) return true;
7273
const dn = u.attributes?.LDAP_ENTRY_DN?.[0] || "";
@@ -77,30 +78,39 @@ Accept: application/json
7778
const chunkSize = 100;
7879
console.log(`==> Verarbeite Benutzer in Blöcken von ${chunkSize}...`);
7980
let processed = 0;
80-
const lines = [];
81+
82+
// Sammle als Objekte
83+
const people = [];
8184

8285
for (let i = 0; i < total; i += chunkSize) {
8386
const chunk = users.slice(i, i + chunkSize);
8487
for (const u of chunk) {
8588
if (inTargetOu(u)) {
8689
const first = (u.firstName ?? "").trim();
8790
const last = (u.lastName ?? "").trim();
88-
const line = `${first} ${last}`.trim();
89-
if (line) lines.push(line);
91+
if (first || last) {
92+
people.push({ firstName: first, lastName: last });
93+
}
9094
}
9195
}
9296
processed = Math.min(i + chunkSize, total);
9397
console.log(` ... verarbeitet: ${processed}/${total}`);
9498
}
9599

96-
console.log(`==> Fertig. Gefiltert: ${lines.length} Zeilen.`);
100+
console.log(`==> Fertig. Gefiltert: ${people.length} Einträge.`);
97101
if (wantOu) console.log(`==> OU-Filter aktiv: ${wantOu}`);
98102

99-
lines.sort((a,b) => a.localeCompare(b, "de", { sensitivity: "base" }));
103+
// Sortiere: lastName → firstName (deutsche Sortierung, case-insensitive)
104+
people.sort((a, b) => {
105+
const ln = (a.lastName || "").localeCompare(b.lastName || "", "de", { sensitivity: "base" });
106+
if (ln !== 0) return ln;
107+
return (a.firstName || "").localeCompare(b.firstName || "", "de", { sensitivity: "base" });
108+
});
100109

101110
console.log("\n=== KOPIERBARE LISTE ===");
102-
for (const line of lines) {
103-
console.log("@@@" + line);
111+
// Wenn dich das "INFO" stört, könntest du hier alternativ process.stdout.write verwenden.
112+
for (const o of people) {
113+
console.log(`@@@ ${o.firstName} ${o.lastName}`.trim());
104114
console.log("");
105115
console.log("@@@");
106116
}

0 commit comments

Comments
 (0)