From 7fc4b8ff6bdcb9789ba89390a17b2c0700707952 Mon Sep 17 00:00:00 2001 From: Bruno Nardini Date: Fri, 25 Oct 2024 17:28:53 -0300 Subject: [PATCH] feat: add Google LDAP vendor Signed-off-by: Bruno Nardini --- plugins/catalog-backend-module-ldap/src/ldap/client.ts | 4 ++++ .../catalog-backend-module-ldap/src/ldap/vendors.ts | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/plugins/catalog-backend-module-ldap/src/ldap/client.ts b/plugins/catalog-backend-module-ldap/src/ldap/client.ts index 48a3eedfb8..61dd05f437 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/client.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/client.ts @@ -25,6 +25,7 @@ import { AEDirVendor, ActiveDirectoryVendor, DefaultLdapVendor, + GoogleLdapVendor, FreeIpaVendor, LdapVendor, } from './vendors'; @@ -236,6 +237,7 @@ export class LdapClient { if (this.vendor) { return this.vendor; } + const clientHost = this.client?.host || ''; this.vendor = this.getRootDSE() .then(root => { if (root && root.raw?.forestFunctionality) { @@ -244,6 +246,8 @@ export class LdapClient { return FreeIpaVendor; } else if (root && 'aeRoot' in root.raw) { return AEDirVendor; + } else if (clientHost === 'ldap.google.com') { + return GoogleLdapVendor; } return DefaultLdapVendor; }) diff --git a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts index 8b84002c20..eac8481c3e 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/vendors.ts @@ -89,6 +89,16 @@ export const AEDirVendor: LdapVendor = { }, }; +export const GoogleLdapVendor: LdapVendor = { + dnAttributeName: 'dn', + uuidAttributeName: 'uid', + decodeStringAttribute: (entry, name) => { + return decode(entry, name, value => { + return value.toString(); + }); + }, +}; + // Decode an attribute to a consumer function decode( entry: SearchEntry,