From 7fa54c3c77850830ca84608f5942d917e6c06ffb Mon Sep 17 00:00:00 2001 From: Tim Buchwaldt Date: Mon, 29 Aug 2022 16:08:25 +0200 Subject: [PATCH] Enable ae-dir LDAP vendor. Signed-off-by: Tim Buchwaldt --- .changeset/many-rules-raise.md | 5 +++++ plugins/catalog-backend-module-ldap/src/ldap/client.ts | 3 +++ plugins/catalog-backend-module-ldap/src/ldap/read.ts | 1 - .../catalog-backend-module-ldap/src/ldap/vendors.ts | 10 ++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .changeset/many-rules-raise.md diff --git a/.changeset/many-rules-raise.md b/.changeset/many-rules-raise.md new file mode 100644 index 0000000000..40a26a85fe --- /dev/null +++ b/.changeset/many-rules-raise.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-ldap': patch +--- + +Added ae-dir LDAP vendor to correctly extract DN. diff --git a/plugins/catalog-backend-module-ldap/src/ldap/client.ts b/plugins/catalog-backend-module-ldap/src/ldap/client.ts index 0afeb16248..410318197e 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/client.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/client.ts @@ -24,6 +24,7 @@ import { ActiveDirectoryVendor, DefaultLdapVendor, FreeIpaVendor, + AEDirVendor, LdapVendor, } from './vendors'; @@ -226,6 +227,8 @@ export class LdapClient { return ActiveDirectoryVendor; } else if (root && root.raw?.ipaDomainLevel) { return FreeIpaVendor; + } else if (root && 'aeRoot' in root.raw) { + return AEDirVendor; } return DefaultLdapVendor; }) diff --git a/plugins/catalog-backend-module-ldap/src/ldap/read.ts b/plugins/catalog-backend-module-ldap/src/ldap/read.ts index 420ba141fc..590d27ba8b 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/read.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/read.ts @@ -128,7 +128,6 @@ export async function readLdapUsers( mapReferencesAttr(user, vendor, map.memberOf, (myDn, vs) => { ensureItems(userMemberOf, myDn, vs); }); - entities.push(entity); }); diff --git a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts index d2df250638..02329b90b3 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts @@ -73,6 +73,16 @@ export const FreeIpaVendor: LdapVendor = { }, }; +export const AEDirVendor: LdapVendor = { + dnAttributeName: 'dn', + uuidAttributeName: 'entryUUID', + decodeStringAttribute: (entry, name) => { + return decode(entry, name, value => { + return value.toString(); + }); + }, +}; + // Decode an attribute to a consumer function decode( entry: SearchEntry,