test(samba): refs #5770 try to use ldap to add group

This commit is contained in:
Javier Segarra 2024-05-15 17:36:33 +02:00
parent d0e836b51e
commit 37ad179676
1 changed files with 24 additions and 4 deletions

View File

@ -119,6 +119,10 @@ module.exports = class SambaHelper {
} }
async syncFromDB() { async syncFromDB() {
// await this.adClient.del(
// `cn=developer,${this.fullGroupsDn}`,
// );
// OBTENER ROLES // OBTENER ROLES
await this.getRoles(); await this.getRoles();
// const rolesKeys = Array.from(this.roles.keys()).sort(); // const rolesKeys = Array.from(this.roles.keys()).sort();
@ -156,6 +160,19 @@ module.exports = class SambaHelper {
if (this.rolesToInsert.length > 0) { if (this.rolesToInsert.length > 0) {
// PROCEDIMIENTO PARA INSERTAR ROLES // PROCEDIMIENTO PARA INSERTAR ROLES
// for (const $role of this.rolesToInsert) {
// const {name, description} = this.roles.get($role);
// const changed = await this.adClient.add(
// `cn=${$role},${this.fullGroupsDn}`,
// {
// cn: $role,
// description: description,
// objectClass: ['top', 'posixGroup', 'sambaGroupMapping']
// }
// );
// console.log(changed);
// }
const resultsRoleInsert = await Promise.all( const resultsRoleInsert = await Promise.all(
this.rolesToInsert.map(role => this.addRole(this.roles.get(role)))); this.rolesToInsert.map(role => this.addRole(this.roles.get(role))));
printResults(resultsRoleInsert); printResults(resultsRoleInsert);
@ -168,10 +185,13 @@ module.exports = class SambaHelper {
const groupDescriptionAttribute = { const groupDescriptionAttribute = {
description: this.roles.get(role).$description, description: this.roles.get(role).$description,
}; };
const changed = await this.adClient.modify(`cn=${role},${this.fullGroupsDn}`, new ldap.Change({ const changed = await this.adClient.modify(
operation: 'replace', `cn=${role},${this.fullGroupsDn}`,
modification: groupDescriptionAttribute, new ldap.Change({
})); operation: 'replace',
modification: groupDescriptionAttribute,
})
);
console.log(changed); console.log(changed);
// await this.deleteRole(role); // await this.deleteRole(role);
// await this.addRole(this.roles.get(role)); // await this.addRole(this.roles.get(role));