@ fama
Вы можете использовать мой ниже фрагмент
let adminUserObj = await client.setUserContext({
username: admins.username,
password: admins.secret
});
let caClient = client.getCertificateAuthority();
let affiliationService = caClient.newAffiliationService();
// Check if organization exists
let registeredAffiliations = await affiliationService.getAll(adminUserObj);
if (!registeredAffiliations.result.affiliations.some(x => x.name == userOrg.toLowerCase())) {
let affiliation = userOrg.toLowerCase() + '.department1';
await affiliationService.create({
name: affiliation,
force: true
}, adminUserObj);
}