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,